I interact with a C framework using pythons ctypes, sometimes I get a segmentation fault when dereferencing a ctypes struct pointer.
To debug the segmentation fault I decided to install and enable faulthandler. (faulthandler is not default in 2.7)
However, when I run my code with faulthandler.enable() in the code it runs flawless. Removing the faulthandler.enable() makes my segmentation faults appear again.
Is there something that faulthandler changes to the execution of the python code that can explain the disappearance of segmentation faults?
edit
The problem was solved because faulthandler overrides the signal for segmentation faults, it does so because it still needs to generate a stacktrace before closing the process.
I think the SEGV was signalled because the memory got out of scope in C, but was not reallocated yet. The memory was still in tact which allowed me to still access the memory in python with a <pointer>.from_address
, it seems that because python could still access the memory value faulthandler did not generate a stacktrace.
My problem is already solved by creating an alternate construction, I hope it still helps others that run into this mystery.