"argus_thread" received signal SIGSEGV, Segmentation fault

I am using a Jetson Nano B01 board on a custom carrier board. When trying to use nvarguscamerasrc in a gstreamer pipeline that ends with appsink, a blank image gets saved with terminal output being Segmentation Fault [core dumped]. The python script should capture images until stopped with Ctrl-C. Both python and C++ scripts work on the Jetson Xavier AGX for reference. The gstreamer pipeline in the code also works from terminal can captures the correct image. Code below:

import cv2

cap = cv2.VideoCapture("nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), format=NV12, width=4056, height=3040, framerate=20/1 ! nvvidconv flip-method=0 ! 
videoconvert! video/x-raw, format=BGR ! appsink", cv2.CAP_GSTREAMER)

i = 0;
while(cap.isOpened()):
    ret, frame = cap.read()
    if ret == False:
        break
    cv2.imwrite('image'+str(i)+'.jpg',frame)
    i+=1

cap.release()
cv2.destroyAllWindows()

Terminal output:

GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 13000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 4 
   Output Stream W = 4056 H = 3040 
   seconds to Run    = 0 
   Frame Rate = 22.000001 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global /home/nanosd/opencv/modules/videoio/src/cap_gstreamer.cpp (1081) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
^CTraceback (most recent call last):
  File "test.py", line 9, in <module>
    cv2.imwrite('image'+str(i)+'.jpg',frame)
KeyboardInterrupt
GST_ARGUS: Cleaning up
Segmentation fault (core dumped)

Also used the same pipeline in a C++ script and ran with gdb and verbose error messages are below:

GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...(no debugging symbols found)...done.
(gdb) r
Starting program: /home/nanosd/door_SLAM/camera_stuff/final_codes/FOV:250/stitch/src/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fae2a9db0 (LWP 9717)]
[New Thread 0x7fadaa8db0 (LWP 9718)]
[New Thread 0x7fad2a7db0 (LWP 9719)]
[New Thread 0x7facaa6db0 (LWP 9720)]
[New Thread 0x7faac9fdb0 (LWP 9721)]
[New Thread 0x7faa49edb0 (LWP 9722)]
[New Thread 0x7fa9c9ddb0 (LWP 9723)]
[New Thread 0x7fa949cdb0 (LWP 9725)]
GST_ARGUS: Creating output stream
[New Thread 0x7fa8c6bdb0 (LWP 9783)]
[New Thread 0x7fa3ffedb0 (LWP 9784)]
[New Thread 0x7fa37fddb0 (LWP 9785)]
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 13000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 4 
   Output Stream W = 4056 H = 3040 
   seconds to Run    = 0 
   Frame Rate = 22.000001 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[New Thread 0x7fa1e58db0 (LWP 9788)]
[ WARN:0] global /home/nanosd/opencv/modules/videoio/src/cap_gstreamer.cpp (1081) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
frame:0
Resolution of the video: 4056 x 3040
capturing image.
done capturing.
GST_ARGUS: Cleaning up
[Thread 0x7fa37fddb0 (LWP 9785) exited]
[Thread 0x7fa8c6bdb0 (LWP 9783) exited]

Thread 11 "argus_thread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fa3ffedb0 (LWP 9784)]
0x0000007fb0790508 in ?? () from /usr/lib/aarch64-linux-gnu/tegra/libnvargus_socketclient.so
(gdb) c
Continuing.
[Thread 0x7fa1e58db0 (LWP 9788) exited]
[Thread 0x7fa3ffedb0 (LWP 9784) exited]
[Thread 0x7fa949cdb0 (LWP 9725) exited]
[Thread 0x7fa9c9ddb0 (LWP 9723) exited]
[Thread 0x7faa49edb0 (LWP 9722) exited]
[Thread 0x7faac9fdb0 (LWP 9721) exited]
[Thread 0x7facaa6db0 (LWP 9720) exited]
[Thread 0x7fad2a7db0 (LWP 9719) exited]
[Thread 0x7fadaa8db0 (LWP 9718) exited]
[Thread 0x7fae2a9db0 (LWP 9717) exited]

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) 
The program is not being run.
(gdb) q

I found a similar topic here:

with a solution of patching the gstnvarguscamerasrc.cpp file, but I was unable to find that file in the root directory, nor the L4T source code. Can anyone help?

Hi Josh,
You can find the source files in this link: public_sources.tbz2
Once you unpack, cd into Linux_for_Tegra/source/public and unpack gst-nvarguscamera_src.tbz2
Then cd into gst-nvarguscamera and apply the patch to the file.
Once you have a new compiled libgstnvarguscamerasrc.so you’ll need to make a backup copy and replace the original one in /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvarguscamerasrc.so.
Then restart the nvargus-daemon: sudo systemctl restart nvargus-daemon

Hey @guilhermess ,

Thank you so much for this. I found the source file location and applied the patch, but it seems to have not worked, as now when I run get-launch-1.0 from terminal I get the resulting error:

gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=4056, height=3040, framerate=1/5, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=822, height=616' ! nvjpegenc ! filesink location=Image.jpg
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
Caught SIGSEGV
#0  0x0000007f7b0e9e28 in __GI___poll (fds=0x556c952130, nfds=547526505016, timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:41
#1  0x0000007f7b1f6e08 in  () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2  0x000000556c7d2b00 in  ()
Spinning.  Please run 'gdb gst-launch-1.0 7668' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:13.352384323
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Segmentation fault (core dumped)

Also, here is the output after compiling the patched gstnvarguscamerasrc.cpp script:

make
g++ -c gstnvarguscamerasrc.cpp  -fPIC `pkg-config --cflags gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 gstreamer-allocators-1.0 glib-2.0` -I./ -I../ -I/usr/src/jetson_multimedia_api/include/ -I/usr/src/jetson_multimedia_api/argus/samples/utils/ -o gstnvarguscamerasrc.o
gstnvarguscamerasrc.cpp: In member function ‘virtual bool ArgusCamera::StreamConsumer::threadExecute(GstNvArgusCameraSrc*)’:
gstnvarguscamerasrc.cpp:334:77: warning: format not a string literal and no format arguments [-Wformat-security]
       error = g_error_new (domain, argusStatus, getStatusString(argusStatus));
                                                                             ^
gstnvarguscamerasrc.cpp:356:83: warning: format not a string literal and no format arguments [-Wformat-security]
           error = g_error_new (domain, frame_status, getStatusString(frame_status));
                                                                                   ^
g++ -c gstnvarguscamera_utils.cpp  -fPIC `pkg-config --cflags gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 gstreamer-allocators-1.0 glib-2.0` -I./ -I../ -I/usr/src/jetson_multimedia_api/include/ -I/usr/src/jetson_multimedia_api/argus/samples/utils/ -o gstnvarguscamera_utils.o
g++ -shared -o libgstnvarguscamerasrc.so gstnvarguscamerasrc.o gstnvarguscamera_utils.o -lnvbuf_utils -lnvdsbufferpool -lnvargus_socketclient -lpthread `pkg-config --libs gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 gstreamer-allocators-1.0 glib-2.0` -Wl,--no-undefined -L/usr/lib/aarch64-linux-gnu/tegra/ -Wl,-rpath,/usr/lib/aarch64-linux-gnu/tegra/

Hi Josh,
Let’s cover some simple things quickly: did you restart the nvargus-daemon after you replaced the library, and did you try restarting jetson? If you rollback to the original .so does it get past reading of the sensor modes?

From your log, it seems to be crashing while reading the sensor modes, and this part of the code is not touched in the patch.
If restarting doesn’t work then I suggest trying to compile libgstnvarguscamerasrc.so with debug symbols: add -g option to line 52 in Makefile: CFLAGS += -fPIC -g, recompile, replace the .so in the system and run with gdb and get a backtrace (type bt in the gdb terminal after the crash).

Hey @guilhermess ,

Yes I restarted the nvargus-daemon and restarted the Jetson Nano after replacing the library. When going back to the original .so I can read sensor modes and capture images correctly.

Below is the output of the compilation with debug symbols in the makefile, and get-launch-1.0 ran with gdb commands:

sudo gdb gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! 'video/x-raw(memory:NVMM),width=4056, height=3040, framerate=1/5, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=822, height=616' ! nvjpegenc ! filesink location=Image.jpg
Excess command line arguments ignored. (sensor-id=0 ...)
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gst-launch-1.0...(no debugging symbols found)...done.
/home/nanosd0/nvarguscamerasrc: No such file or directory.
(gdb) r
Starting program: /usr/bin/gst-launch-1.0 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
ERROR: pipeline could not be constructed: empty pipeline not allowed.
[Inferior 1 (process 7827) exited with code 01]
(gdb) q

As you can see, the get-launch-1.0 stopped at a different place this time, I suspect it is stopping early because of the gdb, maybe it is not able to find a proper place to store core dumps. What do you advise next?

@josh1
What’s your version?

sudo cat /etc/nv_tegra_release

You should able found correct version from below link. Check the Jetson Linux Driver Package(L4T)

Hey @ShaneCCC

Version below:

sudo cat /etc/nv_tegra_release
# R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t210ref, EABI: aarch64, DATE: Fri Feb 19 16:45:52 UTC 2021

I was able to find the correct version and apply the patch that was suggested in the previous version of this question, but the patch did not help. I am now looking for more way to debug the nvarguscamera pipeline. Do you have any advice?

Could you check if gst-launch-1.0 have the same problem?

@ShaneCCC

gst-launch-1.0 does work correctly from terminal, I cam able to capture images, videos, and appsink. The issues only arises when nvarguscamera is called from python or C++. Also tested in the python subshell in terminal which does not work.

What if don’t write jpg file?

same error:

GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 13000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 1920 x 1080 FR = 89.000000 fps Duration = 11235955 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 18000, max 660000000;

GST_ARGUS: 4056 x 3040 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 3840 x 2160 FR = 22.000001 fps Duration = 45454544 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: 1280 x 720 FR = 16.000000 fps Duration = 62500000 ; Analog Gain range min 1.000000, max 356.175995; Exposure Range min 24000, max 660000000;

GST_ARGUS: Running with following settings:
   Camera index = 0 
   Camera mode  = 4 
   Output Stream W = 4056 H = 3040 
   seconds to Run    = 0 
   Frame Rate = 22.000001 
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
GST_ARGUS: Cleaning up
Segmentation fault (core dumped)

What’s the openCV version?
Does the TX2/Xavier run with the same release BSP and same configure?

OpenCV Version on both Xavier AGX and Jetson Nano:

>>> import cv2
>>> cv2.__version__
'4.1.1'

Jetson Nano BSP:

nanosd0@nanosd0:~$ uname -a
Linux nanosd0 4.9.201-framos-2810 #1 SMP PREEMPT Thu May 6 09:08:40 CEST 2021 aarch64 aarch64 aarch64 GNU/Linux

Xavier BSP:

door@door-xavier:~$ uname -a
Linux door-xavier 4.9.140-framos-2600 #1 SMP PREEMPT Tue Dec 1 21:36:26 CET 2020 aarch64 aarch64 aarch64 GNU/Linux

Check the BSP version by below command

cat /etc/nv_tegra_release

Xavier:

door@door-xavier:~$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 4.4, GCID: 23942405, BOARD: t186ref, EABI: aarch64, DATE: Fri Oct 16 19:37:08 UTC 2020

Jetson Nano:

nanosd0@nanosd0:~$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 5.1, GCID: 26202423, BOARD: t210ref, EABI: aarch64, DATE: Fri Feb 19 16:45:52 UTC 2021

Could you check latest release r32.6.1 or r32.4.4 the same with Xavier on Nano

You may try adding drop=1 into appsink properties:

cap = cv2.VideoCapture("nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), format=NV12, width=4056, height=3040, framerate=22/1 ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)

I’m experiencing the same thing here… Before traveling down the path of patching something that might not actually fix anything, has anyone found another solution?

Meant to say that I quickly tried this with no effect.