basler / pypylon

The official python wrapper for the pylon Camera Software Suite
http://www.baslerweb.com
BSD 3-Clause "New" or "Revised" License
558 stars 207 forks source link

_genicam.RuntimeException: NULL pointer dereferenced : RuntimeException thrown #544

Closed Simonm952 closed 1 year ago

Simonm952 commented 1 year ago

Hi,

I am using a Nvidia Xavier NX device with JetPack 4.6, L4T 32.6.1 OS flashed on an SSD, so it is getting booted from this external storage. I connect an USB Basler camera to this device.

I am using pylon version 6, pypylon 1.8.0 and python 3.7.

When running

pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())

I am getting an error:

NULL pointer dereferenced : RuntimeException thrown (file 'PylonPowerNodeMap.h', line 172).

from pypylon import pylon

for i in pylon.TlFactory.GetInstance().EnumerateDevices():
    print("connected camera sid", i.GetSerialNumber())

cam = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
cam.Open()
print(cam.GetDeviceInfo)
cam.Close()

Using the pylon viewer or the C++ code I am able to take images without any issues.

For another project I am using a Nvidia Xavier AGX without the OS flashed on an SSD and here the pypylon SDK is working.

I also tried installing different pylon, pypylon and python versions but it is always giving the same NULL pointer dereferenced error.

I am wondering if booting from the SSD is causing this issue and if there is a possible solution for this?

Thanks

thiesmoeller commented 1 year ago

can you please start your script in gdb and show the backtrace:

Simonm952 commented 1 year ago

Thanks @thiesmoeller for the reply.

This is the backtrace:

0 0x0000007fb5e8b648 in std::istream::read(char*, long) () from /usr/lib/aarch64-linux-gnu/libstdc++.so.6

1 0x0000007fb5bd7848 in GenApi_3_1_Basler_pylon::CProperty::FromFile(std::istream&) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libNodeMapData_gcc_v3_1_Basler_pylon.so

2 0x0000007fb61606d8 in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libGenApi_gcc_v3_1_Basler_pylon.so

3 0x0000007fb6160da8 in GenApi_3_1_Basler_pylon::CNodeMapFactory::CNodeMapFactoryImpl::CacheRead(unsigned int, GenICam_3_1_Basler_pylon::gcstring, GenApi_3_1_Basler_pylon::INodeMapPrivate*, GenApi_3_1_Basler_pylon::CLock) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libGenApi_gcc_v3_1_Basler_pylon.so

4 0x0000007fb6161a48 in GenApi_3_1_Basler_pylon::CNodeMapFactory::CNodeMapFactoryImpl::Preprocess(GenICam_3_1_Basler_pylon::gcstring, GenApi_3_1_Basler_pylon::INodeMapPrivate*, GenApi_3_1_Basler_pylon::CLock) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libGenApi_gcc_v3_1_Basler_pylon.so

5 0x0000007fb6163048 in GenApi_3_1_Basler_pylon::CNodeMapFactory::CNodeMapFactoryImpl::CreateNodeMap(GenICam_3_1_Basler_pylon::gcstring const&, GenApi_3_1_Basler_pylon::CLock*, bool) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libGenApi_gcc_v3_1_Basler_pylon.so

6 0x0000007faac836c0 in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylon_TL_usb-6.1.0.so

7 0x0000007faac8386c in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylon_TL_usb-6.1.0.so

8 0x0000007faac7648c in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylon_TL_usb-6.1.0.so

9 0x0000007faac93448 in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylon_TL_usb-6.1.0.so

10 0x0000007faac947d8 in ?? () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylon_TL_usb-6.1.0.so

11 0x0000007fb6a4df18 in Pylon::CTlFactory::InternalCreateDevice(Pylon::CDeviceInfo const&, GenICam_3_1_Basler_pylon::gcstring_vector const&, bool) () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylonbase-6.1.0.so

12 0x0000007fb6a4dd6c in Pylon::CTlFactory::CreateDevice(Pylon::CDeviceInfo const&) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylonbase-6.1.0.so

13 0x0000007fb6a4e0d8 in Pylon::CTlFactory::InternalCreateDevice(Pylon::CDeviceInfo const&, GenICam_3_1_Basler_pylon::gcstring_vector const&, bool) () from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylonbase-6.1.0.so

14 0x0000007fb6a4de14 in Pylon::CTlFactory::CreateFirstDevice(Pylon::CDeviceInfo const&) ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/libpylonbase-6.1.0.so

15 0x0000007fb7684d84 in _wrap_TlFactory_CreateFirstDevice ()

from /home/simon/.local/lib/python3.7/site-packages/pypylon/_pylon.cpython-37m-aarch64-linux-gnu.so

16 0x00000000005a7204 in cfunction_call_varargs (kwargs=, args=,

func=<built-in method TlFactory_CreateFirstDevice of module object at remote 0x7fb7706d70>) at ../Objects/call.c:772

17 PyCFunction_Call (func=<built-in method TlFactory_CreateFirstDevice of module object at remote 0x7fb7706d70>,

args=<optimized out>, kwargs=<optimized out>) at ../Objects/call.c:788

18 0x0000000000513300 in do_call_core (kwdict=0x0,

callargs=(<TlFactory(this=<SwigPyObject at remote 0x7fb791d2d0>) at remote 0x7fb782ef90>,),
func=<built-in method TlFactory_CreateFirstDevice of module object at remote 0x7fb7706d70>) at ../Python/ceval.c:4641

19 _PyEval_EvalFrameDefault (

f=f@entry=Frame 0x7fb7817c90, for file /home/simon/.local/lib/python3.7/site-packages/pypylon/pylon.py, line 1582, in CreateFirstDevice (self=<TlFactory(this=<SwigPyObject at remote 0x7fb791d2d0>) at remote 0x7fb782ef90>, args=()), throwflag=throwflag@entry=0)
at ../Python/ceval.c:3191

20 0x000000000050b47c in PyEval_EvalFrameEx (throwflag=0,

f=Frame 0x7fb7817c90, for file /home/simon/.local/lib/python3.7/site-packages/pypylon/pylon.py, line 1582, in CreateFirstDevice (self=<TlFactory(this=<SwigPyObject at remote 0x7fb791d2d0>) at remote 0x7fb782ef90>, args=())) at ../Python/ceval.c:547

21 _PyEval_EvalCodeWithName (_co=, globals=, locals=, args=,

argcount=<optimized out>, kwnames=<optimized out>, kwargs=<optimized out>, kwcount=<optimized out>, kwstep=1, defs=0x0,
defcount=0, kwdefs=0x0, closure=0x0, name='CreateFirstDevice', qualname='TlFactory.CreateFirstDevice') at ../Python/ceval.c:3930

22 0x00000000005a77c8 in _PyFunction_FastCallKeywords (func=, stack=0x7fb78bd5d0, nargs=1, kwnames=)

at ../Objects/call.c:425

23 0x000000000050e69c in call_function (kwnames=0x0, oparg=, pp_stack=0x7fffffee40) at ../Python/ceval.c:4616

24 _PyEval_EvalFrameDefault (

f=f@entry=Frame 0x7fb78bd450, for file /home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py, line 8, in <module> (), throwflag=throwflag@entry=0) at ../Python/ceval.c:3110

25 0x000000000050b47c in PyEval_EvalFrameEx (throwflag=0,

f=Frame 0x7fb78bd450, for file /home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py, line 8, in <module> ()) at ../Python/ceval.c:547

26 _PyEval_EvalCodeWithName (_co=, globals=, locals=, args=,

argcount=<optimized out>, kwnames=<optimized out>, kwargs=<optimized out>, kwcount=<optimized out>, kwstep=2, defs=0x0,

---Type to continue, or q to quit--- defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at ../Python/ceval.c:3930

27 0x000000000050dd70 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0,

args=0x0, locals=<optimized out>, globals=<optimized out>, _co=<optimized out>) at ../Python/ceval.c:3959

28 PyEval_EvalCode (co=, globals=, locals=) at ../Python/ceval.c:524

29 0x0000000000616f84 in run_mod (mod=mod@entry=0x948ed0,

filename=filename@entry='/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py',
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py') at remote 0x7fb78e7150>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7fb79a6d10>, '__file__': '/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py', '__cached__': None, 'pylon': <module at remote 0x7fb78301d0>, 'cdll': <LibraryLoader(_dlltype=<type at remote 0xb5e5f0>) at remote 0x7fac34f0d0>, 'os': <module at remote 0x7fb78e6a70>, 'subprocess': <module at remote 0x7fac4b6d10>, 'time': <module at remote 0x7fac695710>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py') at remote 0x7fb78e7150>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7fb79a6d10>, '__file__': '/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py', '__cached__': None, 'pylon': <module at remote 0x7fb78301d0>, 'cdll': <LibraryLoader(_dlltype=<type at remote 0xb5e5f0>) at remote 0x7fac34f0d0>, 'os': <module at remote 0x7fb78e6a70>, 'subprocess': <module at remote 0x7fac4b6d10>, 'time': <module at remote 0x7fac695710>}, flags=flags@entry=0x7ffffff118, arena=arena@entry=0x7fb793d770)
at ../Python/pythonrun.c:1035

30 0x0000000000617070 in PyRun_FileExFlags (fp=fp@entry=0x9316c0,

filename_str=filename_str@entry=0x7fb789ddd0 "/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py", start=start@entry=257,
globals=globals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py') at remote 0x7fb78e7150>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7fb79a6d10>, '__file__': '/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py', '__cached__': None, 'pylon': <module at remote 0x7fb78301d0>, 'cdll': <LibraryLoader(_dlltype=<type at remote 0xb5e5f0>) at remote 0x7fac34f0d0>, 'os': <module at remote 0x7fb78e6a70>, 'subprocess': <module at remote 0x7fac4b6d10>, 'time': <module at remote 0x7fac695710>},
locals=locals@entry={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py') at remote 0x7fb78e7150>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7fb79a6d10>, '__file__': '/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py', '__cached__': None, 'pylon': <module at remote 0x7fb78301d0>, 'cdll': <LibraryLoader(_dlltype=<type at remote 0xb5e5f0>) at remote 0x7fac34f0d0>, 'os': <module at remote 0x7fb78e6a70>, 'subprocess': <module at remote 0x7fac4b6d10>, 'time': <module at remote 0x7fac695710>}, closeit=closeit@entry=1, flags=flags@entry=0x7ffffff118)
at ../Python/pythonrun.c:988

31 0x000000000061844c in PyRun_SimpleFileExFlags (fp=0x9316c0,

filename=0x7fb789ddd0 "/home/simon/Documents/Jetson-OPCUA-Communication-master/Client_application/camera.py", closeit=1,
flags=0x7ffffff118) at ../Python/pythonrun.c:429

32 0x00000000006494c8 in pymain_run_file (p_cf=0x7ffffff118, filename=, fp=0x9316c0) at ../Modules/main.c:427

33 pymain_run_filename (cf=0x7ffffff118, pymain=0x7ffffff1b0) at ../Modules/main.c:1606

34 pymain_run_python (pymain=0x7ffffff1b0) at ../Modules/main.c:2867

35 pymain_main (pymain=, pymain=) at ../Modules/main.c:3028

36 0x0000000000649b00 in _Py_UnixMain (argc=, argv=) at ../Modules/main.c:3063

37 0x0000007fb7e787a0 in __libc_start_main (main=0x0, argc=0, argv=0x0, init=, fini=,

rtld_fini=<optimized out>, stack_end=<optimized out>) at ../csu/libc-start.c:310

38 0x00000000005aef1c in _start () at ../Python/pystrtod.c:351

Backtrace stopped: previous frame identical to this frame (corrupt stack?)

thiesmoeller commented 1 year ago

One reason could be a somewhat corrupt binary cache file in the folder $HOME/genicam_xml_cache

can you please try a

rm -r $HOME/genicam_xml_cache
Simonm952 commented 1 year ago

This solved the issue, thanks!