Linux+QT+OpenCv摄像头调试心得(3)---- glibc detected *** free(): invalid pointer: 0xafeff000

摄像头预览正常,在点击“退出按钮”,或者关闭运行窗体后,下面的编译器输出栏弹出一堆警告,如下:

*** glibc detected *** /home/yan/qt/Camera_Read_OpenCv_V1-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK____/Camera_Read_OpenCv_V1: free(): invalid pointer: 0xafeff000 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6ebc2)[0x908bc2]
/lib/i386-linux-gnu/libc.so.6(+0x6f862)[0x909862]
/lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0x90c94d]
/usr/lib/libcxcore.so.2.1(_ZN2cv8fastFreeEPv+0x23)[0xe236a3]
/usr/lib/libcxcore.so.2.1(cvFree_+0x1c)[0xe23c2c]
/usr/lib/libcxcore.so.2.1(cvReleaseImageHeader+0x6a)[0xe5b7ba]
/usr/lib/libcxcore.so.2.1(cvReleaseImage+0x3f)[0xe5b8ff]
/home/yan/qt/Camera_Read_OpenCv_V1-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK____/Camera_Read_OpenCv_V1[0x804a679]
/home/yan/qt/Camera_Read_OpenCv_V1-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK____/Camera_Read_OpenCv_V1[0x804a1f3]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x8b3113]
/home/yan/qt/Camera_Read_OpenCv_V1-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK____/Camera_Read_OpenCv_V1[0x804a249]
======= Memory map: ========
00110000-003f1000 r-xp 00000000 08:01 557615     /home/yan/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4.8.0
003f1000-003f8000 r--p 002e0000 08:01 557615     /home/yan/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4.8.0
003f8000-003fb000 rw-p 002e7000 08:01 557615     /home/yan/QtSDK/Desktop/Qt/4.8.0/gcc/lib/libQtCore.so.4.8.0
003fb000-00417000 r-xp 00000000 08:01 394171     /lib/i386-linux-gnu/libgcc_s.so.1
00417000-00418000 r--p 0001b000 08:01 394171     /lib/i386-linux-gnu/libgcc_s.so.1。。。。。。。。。。。。。。。等等很多

原因:在CameraWidget的析构函数里,释放指针的顺序不对,应该是cvReleaseCapture(&capture),然后再cvReleaseImage(&img); 

备注:img = cvQueryFrame(capture)。  如果内存释放顺序颠倒了,就会出现上述警告! 


你可能感兴趣的:(c,linux,gcc,qt,编译器)