Bug 28352 - Assertion failure when using Python exit event handler: ../../gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed.
Summary: Assertion failure when using Python exit event handler: ../../gdb/thread.c:95...
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 10.1
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-19 03:37 UTC by Parke
Modified: 2021-09-19 03:37 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Parke 2021-09-19 03:37:21 UTC
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