Bug in nvarguscamerasrc with GstRTSPServer
I am playing with the test-launch example linked here. The command I'm executing on my Jetson TX2 (L4T 32.1 and GStreamer 1.14.3) with a Omnivision OV5693 camera which came with the devkit is:
./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM),width=(int)320,height=(int)240,format=(string)NV12,framerate=(fraction)15/1 ! omxh264enc name=omxh264enc control-rate=1 ! video/x-h264,profile=baseline,stream-format=(string)byte-stream ! h264parse ! rtph264pay name=pay0"
And I'm viewing the RTSP stream by running:
gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test latency=100
On the first time I run this, the video feed is displayed perfectly and I am able to see the output from the camera.
However, if I close the stream by exiting playbin and then run gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test latency=100
again, I get no output on the receiver and the test-launch script crashes with a segmentation fault. On closer examination using valgrind, it looks like the crash is due to nvarguscamerasrc. This crash does not happen with v4l2src / uvch264src and did not happen with the older nvcamerasrc element either
The output of running valgrind on the GstRTSPServer launch script is below when I open and close the RTSP stream using the above playbin command:
==20276== Thread 8 argus_thread:
==20276== Invalid read of size 4
==20276== at 0x4D836F0: pthread_mutex_lock (pthread_mutex_lock.c:65)
==20276== by 0x584E097: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so)
==20276== by 0x584CB5F: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so)
==20276== by 0x4A9E98B: ??? (in /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0.5600.4)
==20276== Address 0x68 is not stack'd, malloc'd or (recently) free'd
==20276==
==20276==
==20276== Process terminating with default action of signal 11 (SIGSEGV)
==20276== Access not within mapped region at address 0x68
==20276== at 0x4D836F0: pthread_mutex_lock (pthread_mutex_lock.c:65)
==20276== by 0x584E097: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so)
==20276== by 0x584CB5F: ??? (in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so)
==20276== by 0x4A9E98B: ??? (in /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0.5600.4)
==20276== If you believe this happened as a result of a stack
==20276== overflow in your program's main thread (unlikely but
==20276== possible), you can try to increase the size of the
==20276== main thread stack using the --main-stacksize= flag.
==20276== The main thread stack size used in this run was 8388608.
==20276==
==20276== HEAP SUMMARY:
==20276== in use at exit: 12,157,642 bytes in 31,252 blocks
==20276== total heap usage: 80,451 allocs, 49,199 frees, 47,233,924 bytes allocated
==20276==
==20276== LEAK SUMMARY:
==20276== definitely lost: 18,908 bytes in 21 blocks
==20276== indirectly lost: 1,400 bytes in 1 blocks
==20276== possibly lost: 320,107 bytes in 92 blocks
==20276== still reachable: 11,613,491 bytes in 30,298 blocks
==20276== of which reachable via heuristic:
==20276== length64 : 1,152 bytes in 27 blocks
==20276== newarray : 5,936 bytes in 41 blocks
==20276== multipleinheritance: 1,312 bytes in 2 blocks
==20276== suppressed: 0 bytes in 0 blocks
==20276== Rerun with --leak-check=full to see details of leaked memory
==20276==
==20276== For counts of detected and suppressed errors, rerun with: -v
==20276== Use --track-origins=yes to see where uninitialised values come from
==20276== ERROR SUMMARY: 1013 errors from 16 contexts (suppressed: 0 from 0)
The crash occurs the second time I open the client by using playbin after closing the first one. Maybe nvarguscamerasrc hasn't completely cleaned up the resources or still holds the file descriptor of the camera?