#514·gdbgui

GDB hangs infinitely traversing pretty printers

Author: stgatilovCreated Jun 28, 2026Updated Jun 28, 2026

I have found a relatively general case where the controlled GDB process hangs.

Consider the following:

  1. I use GDB pretty printers on pointers to make them expandable. This makes perfect sense, since otherwise pointers look like dead hex values in the debugger.
  2. The pointer / children graph of some data structures have loops. This makes perfect sense again, there so many data structures with all kind of backlinks that make pointer graph cyclic.
  3. I get into unlucky situation where debugger forces GDB to deep-print cyclic data structure... which never ends.

Steps to reproduce the behavior:

  1. Clone "gdbgui" branch of this repository: https://github.com/stgatilov/vscode-gdb-pretty-printers-hangs-repro-code/tree/gdbgui
  2. Build the code with CMake.
  3. Load the built executable into gdbgui.
  4. Start debugging.
  5. Execute "source path/to/printers.py".
  6. Make sure the file was found and loaded!
  7. Set breakpoint on the last line of "badfunc" function.
  8. Continue execution until the new breakpoint triggers.
  9. Notice that gdb hangs completely.

I captured MI commands using strace, and this is the last command before hanging:

1-stack-list-variables --simple-values

As far as I know, --simple-values means that pointer variables have their values printed (for some reason, they are "simple"). But due to how GDB works by default, it actually tries to deep-print the value, which is an infinitely large task since the children graph has loops.

Other debuggers also have this problem: