Pyzed seg faults on Ubuntu 22?

On Ubuntu 22, using the latest CUDA 12 SDK, when attempting to run any samples or my own software (which works fine on Windows) written in Python, when calling sl.Camera.get_device_list(), python immediately seg faults with the following stack trace:

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
74	../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:74
#1  0x00007ffff7631149 in __pyx_pw_5pyzed_2sl_6Camera_147get_device_list(_object*, _object* const*, long, _object*) () from /home/breakfast/dev/zed-performance-tester/env/lib/python3.10/site-packages/pyzed/sl.cpython-310-x86_64-linux-gnu.so
#2  0x00005555556a28a2 in _PyEval_EvalFrameDefault ()
#3  0x00005555556b470c in _PyFunction_Vectorcall ()
#4  0x000055555569ce0d in _PyEval_EvalFrameDefault ()
#5  0x000055555578de56 in ?? ()
#6  0x000055555578dcf6 in PyEval_EvalCode ()
#7  0x00005555557b87d8 in ?? ()
#8  0x00005555557b20bb in ?? ()
#9  0x00005555557b8525 in ?? ()
#10 0x00005555557b7a08 in _PyRun_SimpleFileObject ()
#11 0x00005555557b7653 in _PyRun_AnyFileObject ()
#12 0x00005555557aa41e in Py_RunMain ()
#13 0x0000555555780cad in Py_BytesMain ()
#14 0x00007ffff7c75d90 in __libc_start_call_main (main=main@entry=0x555555780c70, argc=argc@entry=2, argv=argv@entry=0x7fffffffe3b8) at ../sysdeps/nptl/libc_start_call_main.h:58
#15 0x00007ffff7c75e40 in __libc_start_main_impl (main=0x555555780c70, argc=2, argv=0x7fffffffe3b8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe3a8) at ../csu/libc-start.c:392
#16 0x0000555555780ba5 in _start ()

Not sure how to proceed.

Does the Linux SDK not work?

Thanks
Jason

Hi @JC31 ,

What version of the ZED SDK are you using? Please verify that you are using version 4.0.7, and you can also make sure that the python wrapper is up to date by running the command in your python environment:

python /usr/local/zed/get_python_api.py

I made sure the Python wrapper was up to date and it did not change the behavior.

I can confirm I am using ZED SDK 4.0.7 (for CUDA 12.1, Ubuntu 22).

Other versions of stuff:

$ pip list
Package             Version
------------------- ---------
certifi             2023.7.22
charset-normalizer  3.3.0
Cython              3.0.3
idna                3.4
numpy               1.26.0
opencv-python       4.8.1.78
pip                 22.0.2
PyOpenGL            3.1.6
PyOpenGL-accelerate 3.1.6
pyzed               4.0
pyzedhub            0.73
requests            2.31.0
setuptools          59.6.0
urllib3             2.0.6
wheel               0.41.2

$ python --version
Python 3.10.12

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

$ uname -a
Linux B2CON00011 5.15.0-84-generic #93-Ubuntu SMP Tue Sep 5 17:16:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Ok I found out some more info.

First, the C++ SDK was not experiencing this issue, however, I noticed when running the ZED_Multi_Camera C++ example, it was failing to detect one of the cameras:

$ ./ZED_Multi_Camera 
ID : 0 ,model : ZED 2i , S/N : 30469917 , state : AVAILABLE
ID : -1 ,model : ZED 2i , S/N : 0 , state : NOT AVAILABLE
2 ZED Detected
ZED 2i, ID: 0, SN: 30469917 Opened
ZED ID:1 Error: CAMERA NOT DETECTED

I’ve seen this behavior before on Windows systems too but I don’t know what triggers it.

Anyways, I unplugged and replugged every camera to reboot them, and the C++ example was then able to detect both cameras.

After doing that, the Python examples started working without seg faulting.

So it seems like there is a bug in the Python SDK where a strlen call causes a seg fault in whatever situation happens where there is an error detecting one of the cameras (when its ID returns -1). Probably some nullptr string or something getting passed around somewhere on the C side.

As an aside, I noticed on Windows systems that when the cameras are in this undetectable state, sometimes Python apps will simply silently exit on the Camera.get_device_list() call, and now I’m starting to wonder if that’s just a different manifestation of the same Python SDK bug that’s crashing the Ubuntu SDK.

Thanks for the valuable info. We will look into this to reproduce and find where the code segfaults.

Alternatively, if you experience more issues where the camera returns CAMERA_NOT_DETECTED, you can use the static method sl::reboot and provide a serial number to hard reboot a specific camera without unplugging it.