Bug 24457 - Segfault during gdb.execute('quit') within exit event handler
Summary: Segfault during gdb.execute('quit') within exit event handler
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: python (show other bugs)
Version: 8.2
: P2 normal
Target Milestone: 11.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-16 02:15 UTC by krinkodot22
Modified: 2023-12-16 14:50 UTC (History)
1 user (show)

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 krinkodot22 2019-04-16 02:15:47 UTC
Within a sourced Python script, running `gdb.execute('quit')` during an exit event handler causes a segfault.

To reproduce, run gdb on any executable after sourcing this Python script:

def on_exit(event):
    gdb.execute('quit')
gdb.events.exited.connect(on_exit)

When the inferior ends, gdb should quit, but it segfaults instead.

This happens on gdb 8.2 and newer.

Also reported on RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1684822
Comment 1 Hannes Domani 2022-01-05 16:20:18 UTC
I can reproduce a problem with gdb 10.2:

C:/src/repos/binutils-gdb.git/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.
Quit this debugging session? (y or n) y

But with 11.1 it works for me.

I think it was fixed by:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=219f56b4842f4e72540082af96e47efa0f0f0a82
Comment 2 Hannes Domani 2023-12-16 14:50:53 UTC
(In reply to Hannes Domani from comment #1)
> I can reproduce a problem with gdb 10.2:
> 
> C:/src/repos/binutils-gdb.git/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.
> Quit this debugging session? (y or n) y
> 
> But with 11.1 it works for me.
> 
> I think it was fixed by:
> https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;
> h=219f56b4842f4e72540082af96e47efa0f0f0a82

I'm closing this now.