6

A Python process hangs in futex():

root@pc:~# strace -p 9042
strace: Process 9042 attached
futex(0x1e61900, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, ffffffff

I want to see the stacktrace if the hanging process.

Unfortunately ctrl-c does not work :-(

How can I see the stacktrace if Python hangs like this?

guettli
  • 25,042
  • 81
  • 346
  • 663
  • Just attach gdb to the process, or run pstack if you have it installed. Or `kill -SEGV` the process and examine the core, if you don't need to keep it alive. – Useless Sep 15 '16 at 08:54
  • @Useless I want to see the stacktrace of the python code. Not the stacktrace of the Python interpreter (c code). I looked at pstack, AFAIK pstack prints the latter. – guettli Sep 15 '16 at 09:00

1 Answers1

6
  1. install the gdb python extensions if needed for your system (see here for example, or look at your distro documentation)
  2. attach gdb to your hung process
  3. run

    (gdb) py-bt
    

    instead of regular bt to get the Python backtrace

Useless
  • 64,155
  • 6
  • 88
  • 132
  • After doing the `ln -s ...` commands from another answer, and running gdb as root it worked. Here the other answer: http://stackoverflow.com/a/30430059/633961 – guettli Sep 15 '16 at 10:20