*** glibc detected *** zmc: double free or corruption

Forum for questions and support relating to the 1.24.x releases only.
Locked
BlankMan
Posts: 147
Joined: Tue Jan 19, 2010 2:53 am
Location: Milwaukee, WI USA

*** glibc detected *** zmc: double free or corruption

Post by BlankMan »

Getting this. From what I could find it said it happens when trying to delete when the memory has already been unallocated. ZM 1.23.2 openSuSE 11.3.

Any way to fix it?

Code: Select all

*** glibc detected *** /usr/local/bin/zmc: double free or corruption (!prev): 0x000000000613e200 ***
======= Backtrace: =========                                                                                          
/lib64/libc.so.6(+0x73226)[0x7fc26884d226]                                                                            
/lib64/libc.so.6(cfree+0x6c)[0x7fc268851fcc]                                                                          
/usr/lib64/libavformat.so.52(av_close_input_stream+0x12c)[0x7fc26b1b538c]                                             
/usr/local/bin/zmc[0x41588c]
/usr/local/bin/zmc[0x4158e9]
/usr/local/bin/zmc[0x428a9d]
/usr/local/bin/zmc[0x406dad] 
/lib64/libc.so.6(__libc_start_main+0xfd)[0x7fc2687f8b7d]                                                              
/usr/local/bin/zmc[0x406759]                                                                                          
======= Memory map: ======== 
00400000-0046e000 r-xp 00000000 08:07 1063404            /usr/local/bin/zmc
0066d000-0066e000 r--p 0006d000 08:07 1063404            /usr/local/bin/zmc
0066e000-00678000 rw-p 0006e000 08:07 1063404            /usr/local/bin/zmc
00678000-0645d000 rw-p 00000000 00:00 0                  [heap]            
7fc254000000-7fc254021000 rw-p 00000000 00:00 0                            
7fc254021000-7fc258000000 ---p 00000000 00:00 0                            
7fc25a93b000-7fc25aafe000 rw-p 00000000 00:00 0                            
7fc25aafe000-7fc265ac7000 rw-s 00000000 00:04 884742     /SYSV7a6d000a (deleted)
7fc265ac7000-7fc265c8b000 rw-p 00000000 00:00 0                                 
7fc265c8b000-7fc265c97000 r-xp 00000000 08:01 752        /lib64/libnss_files-2.11.2.so
7fc265c97000-7fc265e96000 ---p 0000c000 08:01 752        /lib64/libnss_files-2.11.2.so
7fc265e96000-7fc265e97000 r--p 0000b000 08:01 752        /lib64/libnss_files-2.11.2.so
7fc265e97000-7fc265e98000 rw-p 0000c000 08:01 752        /lib64/libnss_files-2.11.2.so
7fc265e98000-7fc265ea0000 r-xp 00000000 08:01 765        /lib64/librt-2.11.2.so       
7fc265ea0000-7fc26609f000 ---p 00008000 08:01 765        /lib64/librt-2.11.2.so       
7fc26609f000-7fc2660a0000 r--p 00007000 08:01 765        /lib64/librt-2.11.2.so       
7fc2660a0000-7fc2660a1000 rw-p 00008000 08:01 765        /lib64/librt-2.11.2.so       
7fc2660a1000-7fc2660fa000 r-xp 00000000 08:06 654654     /usr/lib64/liborc-0.4.so.0.0.0
7fc2660fa000-7fc2662fa000 ---p 00059000 08:06 654654     /usr/lib64/liborc-0.4.so.0.0.0
7fc2662fa000-7fc2662fb000 r--p 00059000 08:06 654654     /usr/lib64/liborc-0.4.so.0.0.0
7fc2662fb000-7fc2662ff000 rw-p 0005a000 08:06 654654     /usr/lib64/liborc-0.4.so.0.0.0
7fc2662ff000-7fc266353000 r-xp 00000000 08:01 5602       /lib64/libssl.so.1.0.0        
7fc266353000-7fc266553000 ---p 00054000 08:01 5602       /lib64/libssl.so.1.0.0        
7fc266553000-7fc266556000 r--p 00054000 08:01 5602       /lib64/libssl.so.1.0.0        
7fc266556000-7fc26655b000 rw-p 00057000 08:01 5602       /lib64/libssl.so.1.0.0        
7fc26655b000-7fc266566000 r-xp 00000000 08:06 652677     /usr/lib64/libgsm.so.1.0.13   
7fc266566000-7fc266765000 ---p 0000b000 08:06 652677     /usr/lib64/libgsm.so.1.0.13   
7fc266765000-7fc266766000 r--p 0000a000 08:06 652677     /usr/lib64/libgsm.so.1.0.13   
7fc266766000-7fc266767000 rw-p 0000b000 08:06 652677     /usr/lib64/libgsm.so.1.0.13   
7fc266767000-7fc266796000 r-xp 00000000 08:06 660305     /usr/lib64/libopencore-amrnb.so.0.0.2
7fc266796000-7fc266996000 ---p 0002f000 08:06 660305     /usr/lib64/libopencore-amrnb.so.0.0.2
7fc266996000-7fc266997000 r--p 0002f000 08:06 660305     /usr/lib64/libopencore-amrnb.so.0.0.2
7fc266997000-7fc266998000 rw-p 00030000 08:06 660305     /usr/lib64/libopencore-amrnb.so.0.0.2
7fc266998000-7fc2669ae000 r-xp 00000000 08:06 660293     /usr/lib64/libopencore-amrwb.so.0.0.2
7fc2669ae000-7fc266bad000 ---p 00016000 08:06 660293     /usr/lib64/libopencore-amrwb.so.0.0.2
7fc266bad000-7fc266bae000 r--p 00015000 08:06 660293     /usr/lib64/libopencore-amrwb.so.0.0.2
7fc266bae000-7fc266baf000 rw-p 00016000 08:06 660293     /usr/lib64/libopencore-amrwb.so.0.0.2
7fc266baf000-7fc266bd8000 r-xp 00000000 08:06 654502     /usr/lib64/libopenjpeg.so.2.1.3.0    
7fc266bd8000-7fc266dd7000 ---p 00029000 08:06 654502     /usr/lib64/libopenjpeg.so.2.1.3.0    
7fc266dd7000-7fc266dd8000 r--p 00028000 08:06 654502     /usr/lib64/libopenjpeg.so.2.1.3.0    
7fc266dd8000-7fc266dda000 rw-p 00029000 08:06 654502     /usr/lib64/libopenjpeg.so.2.1.3.0
7fc266dda000-7fc266e92000 r-xp 00000000 08:06 654030     /usr/lib64/libschroedinger-1.0.so.0.3.0
7fc266e92000-7fc267091000 ---p 000b8000 08:06 654030     /usr/lib64/libschroedinger-1.0.so.0.3.0
7fc267091000-7fc267093000 r--p 000b7000 08:06 654030     /usr/lib64/libschroedinger-1.0.so.0.3.0
7fc267093000-7fc267095000 rw-p 000b9000 08:06 654030     /usr/lib64/libschroedinger-1.0.so.0.3.0
7fc267095000-7fc267096000 rw-p 00000000 00:00 0
7fc267096000-7fc2670ae000 r-xp 00000000 08:06 654027     /usr/lib64/libspeex.so.1.5.0
7fc2670ae000-7fc2672ae000 ---p 00018000 08:06 654027     /usr/lib64/libspeex.so.1.5.0
7fc2672ae000-7fc2672af000 r--p 00018000 08:06 654027     /usr/lib64/libspeex.so.1.5.0
7fc2672af000-7fc2672b0000 rw-p 00019000 08:06 654027     /usr/lib64/libspeex.so.1.5.0
7fc2672b0000-7fc2672c8000 r-xp 00000000 08:06 654799     /usr/lib64/libtheoradec.so.1.1.4
7fc2672c8000-7fc2674c7000 ---p 00018000 08:06 654799     /usr/lib64/libtheoradec.so.1.1.4
7fc2674c7000-7fc2674c8000 r--p 00017000 08:06 654799     /usr/lib64/libtheoradec.so.1.1.4
7fc2674c8000-7fc2674c9000 rw-p 00018000 08:06 654799     /usr/lib64/libtheoradec.so.1.1.4
7fc2674c9000-7fc267505000 r-xp 00000000 08:06 654838     /usr/lib64/libtheoraenc.so.1.1.2
7fc267505000-7fc267705000 ---p 0003c000 08:06 654838     /usr/lib64/libtheoraenc.so.1.1.2
7fc267705000-7fc267706000 r--p 0003c000 08:06 654838     /usr/lib64/libtheoraenc.so.1.1.2
7fc267706000-7fc267707000 rw-p 0003d000 08:06 654838     /usr/lib64/libtheoraenc.so.1.1.2
7fc267707000-7fc2678ca000 r-xp 00000000 08:06 654716     /usr/lib64/libvorbisenc.so.2.0.6
7fc2678ca000-7fc267aca000 ---p 001c3000 08:06 654716     /usr/lib64/libvorbisenc.so.2.0.6
7fc267aca000-7fc267ae1000 r--p 001c3000 08:06 654716     /usr/lib64/libvorbisenc.so.2.0.6

mastertheknife
Posts: 678
Joined: Wed Dec 16, 2009 4:32 pm
Location: Israel

Post by mastertheknife »

Hi,

Assuming you are capturing from ffmpeg source type, use ZM from SVN (its patched there) or use this patch by me:

Code: Select all

--- a/src/zm_ffmpeg_camera.cpp
+++ b/src/zm_ffmpeg_camera.cpp
@@ -43,18 +43,27 @@ FfmpegCamera::FfmpegCamera( int p_id, const std::string &p_path, int p_width, in
 
 FfmpegCamera::~FfmpegCamera()
 {
-    av_free( mFrame );
-    av_free( mRawFrame );
-    
-    avcodec_close( mCodecContext );
-    av_free( mCodecContext );
-    av_close_input_file( mFormatContext );
-    av_free( mFormatContext );
+    av_freep( &mFrame );
+    av_freep( &mRawFrame );
 
-	if ( capture )
-	{
-		Terminate();
-	}
+    /* Only free these (in the reverse order) if PrimeCapture() was called, otherwise they are all NULL */
+    if( mConvertContext ) {
+        sws_freeContext( mConvertContext );
+        mConvertContext = NULL;
+    }
+    if( mCodecContext ) {
+       avcodec_close( mCodecContext );
+       av_freep( &mCodecContext );
+    }
+    if( mFormatContext ) {
+        av_close_input_file( mFormatContext );
+        mFormatContext = NULL;
+    }
+
+    if ( capture )
+    {
+        Terminate();
+    }
 }
 
 void FfmpegCamera::Initialise()
@@ -105,6 +114,11 @@ int FfmpegCamera::PrimeCapture()
     // Try and get the codec from the codec context
     if ( (mCodec = avcodec_find_decoder( mCodecContext->codec_id )) == NULL )
         Fatal( "Can't find codec for video stream from %s", mPath.c_str() );
+    
+    // Allocate memory for the new codec context that avcodec_open() will write to.
+    if( (mCodecContext = avcodec_alloc_context()) == NULL) {
+        Fatal( "Codec context allocation failed." );
+    }
 
     // Open the codec
     if ( avcodec_open( mCodecContext, mCodec ) < 0 )

mastertheknife.
Locked