From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v1 3/7] gdb, btrace: do not use btrace_teardown() for an exited thread
Date: Tue, 10 Nov 2026 07:43:12 +0100 [thread overview]
Message-ID: <20261110064317.405487-4-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20261110064317.405487-1-markus.t.metzger@intel.com>
In clear_thread_inferior_resources(), which itself is called from
set_thread_exited(), we call btrace_teardown() to stop recording but
ignore errors.
In the extended-remote case, when the remote target exited and the
connection closed, we first unpush all targets, then exit all inferiors,
which exits all threads:
#0 clear_thread_inferior_resources (tp=0x555558c01d60)
at ...gdb/thread.c:183
#1 0x00005555567f4ad2 in set_thread_exited (tp=0x555558c01d60, exit_code=std::optional [no contained value],
silent=true) at ...gdb/thread.c:243
#2 0x00005555562d7364 in operator() (__closure=0x7fffffffbb37, thr=0x555558c01d60)
at ...gdb/inferior.c:260
#3 0x00005555562db0e9 in intrusive_list<thread_info, intrusive_base_node<thread_info> >::clear_and_dispose<inferior::clear_thread_list()::<lambda(thread_info*)> >(struct {...}) (this=0x55555893a7b8, disposer=...)
at ...gdb/../gdbsupport/intrusive_list.h:529
#4 0x00005555562d7402 in inferior::clear_thread_list (this=0x55555893a7a0)
at ...gdb/inferior.c:256
#5 0x00005555562d7593 in exit_inferior (inf=0x55555893a7a0)
at ...gdb/inferior.c:313
#6 0x00005555567d2858 in generic_mourn_inferior ()
at ...gdb/target.c:3669
#7 0x00005555565ee529 in remote_unpush_target (target=0x555558c1ebc0)
at ...gdb/remote.c:6532
By the time we call target_teardown_btrace() from btrace_teardown(), the
record-btrace target has already been unpushed from that inferior, but it
may not have been closed, yet, if there is more than one inferior. We end
up in the dummy target that throws an error. That error is never caught
and GDB crashes.
This is exposed by gdb.btrace/multi-inferior.exp. For some reason, this
happens after the test completed, so the resulting coredump is shown in
gdb.sum but not in gdb.log, which is why I missed it for so long.
Call the new clear_btrace_resources() instead, which deletes the btrace
target info but does not call any target methods.
---
gdb/thread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/thread.c b/gdb/thread.c
index e2b89afc118..052d499bf7a 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -188,7 +188,7 @@ clear_thread_inferior_resources (struct thread_info *tp)
bpstat_clear (&tp->control.stop_bpstat);
- btrace_teardown (tp);
+ clear_btrace_resources (tp);
thread_cancel_execution_command (tp);
--
2.53.0
________________________________________
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 (89) 99143-0
www.intel.de
Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman
Chairperson of the Supervisory Board: Sonja Pierer
Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
next prev parent reply other threads:[~2026-11-10 6:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 6:43 [PATCH v1 0/7] gdb, btrace: fix unexpected core file Markus Metzger
2026-11-10 6:43 ` [PATCH v1 1/7] gdb, btrace: add clear_btrace_resources() Markus Metzger
2026-11-10 6:43 ` [PATCH v1 2/7] gdb, btrace: disable tracing in linux_btrace_target_info dtor Markus Metzger
2026-11-10 6:43 ` Markus Metzger [this message]
2026-11-10 6:43 ` [PATCH v1 4/7] gdb, btrace: do not stop recording on close Markus Metzger
2026-11-10 6:43 ` [PATCH v1 5/7] gdb, btrace: remove btrace_teardown() Markus Metzger
2026-11-10 6:43 ` [PATCH v1 6/7] gdb, btrace: remove the teardown_btrace() target method Markus Metzger
2026-11-10 6:43 ` [PATCH v1 7/7] gdb, btrace: remove the disconnect() record-btrace " Markus Metzger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261110064317.405487-4-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox