Page 1 of 1

Error, failed to query crop capabilities /dev/video0

Posted: Fri Dec 31, 2010 12:00 pm
by rhanrick
Distribution: Centos 5.5 Trixbox


I have been trying to track down the cause of this error above. I have a Logitech QuickCam 4000 which works with ffstream/ffmpeg but wont work in ZoneMinder directly or via ffstream/ffmpeg.

I see some previous posts such as http://www.zoneminder.com/forums/viewtopic.php?p=59472 but no solution.

I downloaded from svn 2 days ago and using the following config directives built the packages;

./configure --with-webdir=/var/www/html/zm --with-cgidir=/var/www/cgi-bin --with-webuser=asterisk --with-webgroup=asterisk ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser ZM_DB_PASS=xxxx --with-mysql=/usr/lib/mysql --with-extralibs="-L/usr/lib -L/usr/lib/mysql" CPPFLAGS="-D__STDC_CONSTANT_MACROS"

(The webuser and webgroup are set to asterisk as this is being built on a Trixbox machine)

The build and installation went without any (major) errors. However when I run zm
~]#service zm start
I defined a camera using ffmpeg and create a Group to view the camera. 1) There is no video
2) there is no option in the web console to view the video
and when I look at the system log I get the following;


Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Failed to capture image from monitor 2 (0/1)]Dec 29 16:33:50 hans *** glibc detected *** /usr/local/bin/zmc: double free or corruption (!prev): 0x0e87e280 ***
Dec 29 16:33:50 hans ======= Backtrace: =========
Dec 29 16:33:50 hans /lib/libc.so.6[0x8f65a5]
Dec 29 16:33:50 hans /lib/libc.so.6(cfree+0x59)[0x8f69e9]
Dec 29 16:33:50 hans /usr/lib/libavformat.so.52(av_close_input_stream+0x7f)[0x492aaf]
Dec 29 16:33:50 hans /usr/lib/libavformat.so.52(av_close_input_file+0x1c)[0x492c9c]
Dec 29 16:33:50 hans /usr/local/bin/zmc[0x805d238]
Dec 29 16:33:50 hans /usr/local/bin/zmc[0x806ef16]
Dec 29 16:33:50 hans /usr/local/bin/zmc[0x804c9dc]
Dec 29 16:33:50 hans /lib/libc.so.6(__libc_start_main+0xdc)[0x8a2e9c]
Dec 29 16:33:50 hans /usr/local/bin/zmc(__gxx_personality_v0+0x3a9)[0x804c211]
Dec 29 16:33:50 hans ======= Memory map: ======== Dec 29 16:33:50 hans 00110000-00131000 r-xp 00000000 03:02 21115297 /usr/lib/libjpeg.so.62.0.0 00131000-00132000 rwxp 00020000 03:02 21115297 /usr/lib/libj
.
.
a lot of debug info
.
.
Dec 29 16:33:50 hans [stack]
Dec 29 16:33:50 hans zmc_m2[5776]: INF [Got signal 6 (Aborted), exiting and forcing backtrace]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Signal address is (nil), from 0xa4d402]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: [0xa4d402]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: [0xa4d402]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6(gsignal+0x50) [0x8b5df0]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6(abort+0x101) [0x8b7701]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6 [0x8ee28b]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6 [0x8f65a5]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6(cfree+0x59) [0x8f69e9]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/lib/libavformat.so.52(av_close_input_stream+0x7f) [0x492aaf]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/lib/libavformat.so.52(av_close_input_file+0x1c) [0x492c9c]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/local/bin/zmc [0x805d238]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/local/bin/zmc [0x806ef16]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/local/bin/zmc [0x804c9dc]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /lib/libc.so.6(__libc_start_main+0xdc) [0x8a2e9c]]
Dec 29 16:33:50 hans zmc_m2[5776]: ERR [Backtrace: /usr/local/bin/zmc(__gxx_personality_v0+0x3a9) [0x804c211]]
Dec 29 16:33:50 hans zmc_m2[5776]: INF [Backtrace complete, please execute the following command for more information]
Dec 29 16:33:50 hans zmc_m2[5776]: INF [addr2line -e /usr/local/bin/zmc(__gxx_personality_v0+0x3a9) 0xa4d402 0xa4d402 0x8b5df0 0x8b7701 0x8ee28b 0x8f65a5 0x8f69e9 0x492aaf 0x492c9c 0x805d238 0x806ef16 0x804c9dc 0x8a2e9c 0x804c211]
Dec 29 16:33:50 hans zmdc[5753]: ERR ['zmc -m 2' exited abnormally, exit status 6]
Dec 29 16:33:50 hans zmdc[5753]: INF [Starting pending process, zmc -m 2]
Dec 29 16:33:50 hans zmdc[6199]: INF ['zmc -m 2' started at 10/12/29 16:33:50]
Dec 29 16:33:50 hans zmdc[5753]: INF ['zmc -m 2' starting at 10/12/29 16:33:50, pid = 6199]
Dec 29 16:33:50 hans zmc_m2[6199]: INF [Debug Level = 0, Debug Log = <none>]

So I ran the command;
~]# addr2line -e /usr/local/bin/zmc 0x58e402 0x58e402 0x71bdf0 0x71d701 0x75428b 0x75c5a5 0x75c9e9 0x492aaf 0x492c9c 0x805d6c8 0x806f3f8 0x804ca7c 0x708e9c 0x804c2b1

And the below was the result;

??:0
??:0
??:0
??:0
??:0
??:0
??:0
??:0
??:0
/root/Zoneminder-svn/zm/src/zm_ffmpeg_camera.cpp:52
/root/Zoneminder-svn/zm/src/zm_monitor.cpp:532
/root/Zoneminder-svn/zm/src/zmc.cpp:290
??:0
??:0

From what I understand the error is due to multiple memory deallocation calls to the same memory to glibc (av_free( mFormatContext );
) from the above code.

Any help on how to proceed would be appreciated.

Richard

Posted: Fri Dec 31, 2010 4:40 pm
by mastertheknife
I have never programmed with ffmpeg's APIs, but after some reading it does seem that ZoneMinder is calling free multiple times.

Please try this patch, patch with patch -p1 -i this.patch.file
1) I replaced av_free() with the safer av_freep(), which sets the pointer to NULL after the data is freed, to avoid freeing the same memory twice.
2) freeing mCodecContext and mFormatContext is unnessecary, closing them should free any used resources automatically.

Code: Select all

--- a/src/zm_ffmpeg_camera.cpp        2010-12-31 19:31:13.754142164 +0200
+++ b/src/zm_ffmpeg_camera.cpp        2010-12-31 19:31:13.770135335 +0200
@@ -43,13 +43,13 @@
 
 FfmpegCamera::~FfmpegCamera()
 {
-    av_free( mFrame );
-    av_free( mRawFrame );
+    av_freep( mFrame );
+    av_freep( mRawFrame );
     
     avcodec_close( mCodecContext );
-    av_free( mCodecContext );
+    mCodecContext = NULL;
     av_close_input_file( mFormatContext );
-    av_free( mFormatContext );
+    mFormatContext = NULL;
 
        if ( capture )
        {
mastertheknife

Error, failed to query crop capabilities /dev/video0

Posted: Sat Jan 01, 2011 12:29 pm
by rhanrick
I applied you patch and it stopped the glibc error message. However when I configure the ffserver/ffmpeg I can see the streaming video via a streaming player (VLC) but it doesnt show in ZM.

I have got the QCam 4000 working by setting it to Video4Linux1 in ZM but now there is a new problem. It appears the analysis daemon is crashing;

Jan 1 20:18:39 hans zmwatch[5577]: INF [Restarting analysis daemon for Qcam, time since last analysis 10 seconds (1293884319-1293884309)]
Jan 1 20:18:39 hans zmdc[5526]: INF ['zma -m 5' starting at 11/01/01 20:18:39, pid = 5682]
Jan 1 20:18:39 hans zmwatch[5577]: INF ['zma -m 5' starting at 11/01/01 20:18:39, pid = 5682]
Jan 1 20:18:39 hans zmdc[5682]: INF ['zma -m 5' started at 11/01/01 20:18:39]
Jan 1 20:18:39 hans zma_m5[5682]: INF [Debug Level = 0, Debug Log = <none>]
Jan 1 20:18:39 hans zma_m5[5682]: INF [In mode 5/1, warming up]
Jan 1 20:18:39 hans zma_m5[5682]: INF [Got signal 11 (Segmentation fault), crashing]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Signal address is 0x8, from 0x8068e12]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /usr/local/bin/zma [0x8068e12]]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /usr/local/bin/zma [0x8068e12]]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /usr/local/bin/zma [0x8070749]]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /usr/local/bin/zma [0x804c5c1]]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /lib/libc.so.6(__libc_start_main+0xdc) [0x8a2e9c]]
Jan 1 20:18:39 hans zma_m5[5682]: ERR [Backtrace: /usr/local/bin/zma [0x804c251]]
Jan 1 20:18:39 hans zma_m5[5682]: INF [Backtrace complete, please execute the following command for more information]
Jan 1 20:18:39 hans zma_m5[5682]: INF [addr2line -e /usr/local/bin/zma 0x8068e12 0x8068e12 0x8070749 0x804c5c1 0x8a2e9c 0x804c251]
Jan 1 20:18:39 hans zmdc[5526]: ERR ['zma -m 5' exited abnormally, exit status 11]


I will start a new thread for this.

Richard