From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4X9kNiq98mpZcD0AWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 01:43:54 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DrUx+MxG; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D9C591E06A; Tue, 10 Nov 2026 01:43:54 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5ED6A1E043 for ; Tue, 10 Nov 2026 01:43:54 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CEB34BA7980 for ; Tue, 10 Nov 2026 06:43:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CEB34BA7980 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DrUx+MxG Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 912004BA2E3E for ; Tue, 10 Nov 2026 06:43:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 912004BA2E3E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 912004BA2E3E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794293008; cv=none; b=rCm/7of086oc92aOcPthRMBrMeIpCHxjldCwK6CU3mlA6ff+ACNKixD1XaKYWprPOLuMJh1XsV2lsro2IBiZHN5xeyjQx2Bxpx624nm4gLl2ROYfd62v4X5KzWiFy/Afh/MnFoeD4z2TTRy2+eTQhpTn6XFwnLQcCrZd4MAgh0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794293008; c=relaxed/simple; bh=+VTOhUeT22SUMiFrIfF4TT7D9ASIf2cFX5ksw8tRiZc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=i2JUkQ+4RPZzyh7n0fpWz+KE9aACrED2nxtL/WLvNul6i8Y4z19AzsaN93xSXyt8C9Ap0TeavQYnqvh8g8XWlbmOjmmYb8BeV74DoMdPC/zYfudUw+vXdbBZs4gCP0u6e/35+jSd/YR2Xzof/TKqxn5W7dyaCnn91KUBxgX/lK8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DrUx+MxG DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 912004BA2E3E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794293008; x=1825829008; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=+VTOhUeT22SUMiFrIfF4TT7D9ASIf2cFX5ksw8tRiZc=; b=DrUx+MxG2frY9IDOmHuAgF/7ErbTC6Rgtbsdti4+JDY5QCaLJ/m5qjxv NODEdp7cNafU9SP7jmwSMktVDwITkSEfi21X1xg4gz5s7V0gPfSw3SmGq ohJLnuwJY0BXZgdLK+siepbMaVi3FWmY9ezwKuCbqCso8IeBOMsZFVfrv iDT+ewEWd2zvVl5VONLm7b/HW86J8g9a4OMVNePwKWpezqZUSlOYuBKc8 qNbuha7jHJIUsdbqoiWItlmE3tchckwErnDM133qPLFzh6fNc3Sbamf9l FyEu7b8PfmC+PVX7GjLHHTDi5hmbUMPqUDr7iQh1kavpetnFiunwwo3fq Q==; X-CSE-ConnectionGUID: GLNV9wZqQMKp33b5KSLgAA== X-CSE-MsgGUID: h5rdsJWgSFS3S57CreUVsA== X-IronPort-AV: E=McAfee;i="6800,10657,11961"; a="2921400" X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="2921400" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:43:28 -0800 X-CSE-ConnectionGUID: a0MEJwHhRI+eoUWvNtUAIg== X-CSE-MsgGUID: LNlMnTSRSfOi6xErOhRQ7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,205,1787036400"; d="scan'208";a="8649330" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2026 22:43:27 -0800 From: Markus Metzger 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 Message-ID: <20261110064317.405487-4-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261110064317.405487-1-markus.t.metzger@intel.com> References: <20261110064317.405487-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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 >::clear_and_dispose >(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.