When using a Python exit_handler, I encountered the following error. To reproduce on Arch Linux: $ gdb --version GNU gdb (GDB) 10.2 [snip] $ gdb -q -ex run /bin/true Reading symbols from /bin/true... (No debugging symbols found in /bin/true) Starting program: /usr/bin/true [Inferior 1 (process 339) exited normally] ../../gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. This is a bug, please report it. For instructions, see: <https://www.gnu.org/software/gdb/bugs/>. Aborted (core dumped) $ cat ~/.gdbinit define hook-quit set confirm off end python def exit_handler ( event ): if hasattr ( event, 'exit_code' ) and event .exit_code == 0: gdb .execute ( "quit" ) gdb .events .exited .connect ( exit_handler ) end ---- I encounter a similar bug on Ubuntu 20.04. Same ~/.gdbinit as above. Same steps to reproduce. A different assertion fails. $ gdb --version GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2 [snip] $ gdb -q -ex run /bin/true Reading symbols from /bin/true... (No debugging symbols found in /bin/true) Starting program: /usr/bin/true [Inferior 1 (process 4134946) exited normally] /build/gdb-OxeNvS/gdb-9.2/gdb/inferior.c:283: internal-error: inferior* find_inferior_pid(int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. Aborted (core dumped) Possibly related: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 https://sourceware.org/bugzilla/show_bug.cgi?id=27682