Debugging Python SegFault with gdb - lmmx/devnotes GitHub Wiki
Resources
Brief workflow
- make a python file e.g.
segger.py
which causes the segfault
- [in a terminal] run
gdb python
- N.B. - this just worked for me, there's mention online of needing to recompile with gdb support on some systems
- in the interactive gdb session, type
run segger.py
[or whatever you called your script], to give something like:
Starting program: /home/myusername/anaconda3/bin/python segger.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff12ab700 (LWP 12345)]
[New Thread 0x7ffff89yz700 (LWP 12346)]
…
[New Thread 0x7ffff89yz700 (LWP 12350)]
Program received signal SIGSEGV, Segmentation fault.
Capitalised_Snake_Case_Ref_1 (a=0x123f4567890a1b23, b=0x7fffabfcdf00 <sipVoidPtr_Type>) at Path/to.c:1343
1234 Path/to.c: {Error message goes here}.
(gdb)
- where:
anaconda3
may differ if you're not using an anaconda3 installation
- number of threads may vary based on your system
Capitalised_Snake_Case_Ref_1
and sipVoidPtr_Type
refer to a function in cpython and variable in C respectively