Debugging conda-python with gdb
Jul 21, 2022
Situation: conda env, python3.9, multiprocessing pool gets stuck
$ gdb python <pid>
Will give you C-level stack frames. Need CPython-level stack frames.
For that, we need python-dbg. Not provided by Conda AFAIK. But the system version works.
$ gdb /conda/python/with/stuck/process <pid>
> source /usr/share/gdb/auto-load/usr/bin/python3.9-gdb.py
> py-bt
> py-[up|down]
> py-locals
> py-list # (print code)
> py-print $var
Some gotchas about spawn vs fork here:
https://britishgeologicalsurvey.github.io/science/python-forking-vs-spawn/