duartej / postproc-alibava

Utilities for post-processing data obtained with the ALIBAVA DAQ system.
0 stars 0 forks source link

Segmentation violation with open_sesame sensor_analysis #21

Closed duartej closed 6 years ago

duartej commented 6 years ago

Weird segmentation violation is spotted in my laptop (4.14.0-3-amd64 # 1 SMP Debian 4.14.17-1 (2018-02-14) x86_64 GNU/Linux) meanwhile in lxplus the behaviour is the expected (2.6.32-696.20.1.el6.x86_64 # 1 SMP Thu Jan 25 16:19:46 CET 2018 x86_64 x86_64 x86_64 GNU/Linux)

In lxplus:

in my laptop:

duartej commented 6 years ago

Whenever a configure function is called (form AlibavaSensorAnalysis class), a crash is produced:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff65d5180 in aa_configure_polarity () from /home/duarte/.local/lib/libAlibavaSensorAnalysis.so
(gdb) backtracke
Undefined command: "backtracke".  Try "help".
(gdb) backtrace
#0  0x00007ffff65d5180 in aa_configure_polarity () from /home/duarte/.local/lib/libAlibavaSensorAnalysis.so
#1  0x00007ffff67e4fce in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#2  0x00007ffff67e493f in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#3  0x00007ffff69f8a74 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#4  0x00007ffff69f8475 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#5  0x000055555564ec10 in PyEval_EvalFrameEx ()
#6  0x000055555564725a in PyEval_EvalCodeEx ()
#7  0x0000555555646ce9 in PyEval_EvalCode ()
#8  0x0000555555677def in ?? ()
#9  0x00005555556729c2 in PyRun_FileExFlags ()
#10 0x0000555555671f1d in PyRun_SimpleFileExFlags ()
#11 0x000055555562093b in Py_Main ()
#12 0x00007ffff6e6da87 in __libc_start_main (main=0x5555556202a0 <main>, argc=2, argv=0x7fffffffe158, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_en
duartej commented 6 years ago

The isssue is not fully understood, but using the solution from a similar problem, although not exactly with the same symptoms, seems to fix the issue.

Not sure where the segfault come. It seems to be from those functions defined in the extern C block of AlibavaSensorAnalysis.cc, which return a memory address to AlibavaSensorAnalysis, in particular the constructor, and the python wrapper dealing with them.

Somehow, after the construction, the pointer to the AlibavaSensorAnalysis instance is not properly interpreted (instead of being a ctypes.c_void_p) is a 32-bit integer, so whenever the python class uses a function with the instance, the instance is given as a 32-bit integer address, while it is suppose to be a 64-bit address. So, is highly dependent of the machine/compiler/....