From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hMGuI9kY+mn//RYAWB0awg (envelope-from ) for ; Tue, 05 May 2026 12:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777998041; bh=V+ogtdUQEzr2TFT0wkxSUlELPMIfANqv25U8XJ3zxR0=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ieeAxHJVKgB1NgNt53cx7mUAUR0jaloqESqxY10Y6Yu5DXozIRnUbU4HHt6bdsGzZ KCpFUhJ2YiU6oCiB2W4rfAvFw6Gawl0eZpXMeg/EaVnfkZVk7QLnAecOCoun7EJLYc EBbd9Ha2JgIyYrZ45cvO9j4vMIYpl7LneL2hKxjg= Received: by simark.ca (Postfix, from userid 112) id 7DA011E0BA; Tue, 05 May 2026 12:20:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=WokAkKDz; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 114491E067 for ; Tue, 05 May 2026 12:20:41 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 1C6224BA7995 for ; Tue, 5 May 2026 16:20:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C6224BA7995 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=WokAkKDz Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id DC42E4BA7993 for ; Tue, 5 May 2026 16:20:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC42E4BA7993 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DC42E4BA7993 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777998006; cv=none; b=jBI8lqPlccyMdhl7/GYxo6JnUn4rsWlWDn1JJtUnebcecFkwi17LL/p47zE7GMOe7yOMqNfDAQmy++yTuiPaBatRExpxkXAy/auQWU3c3X3wI5BuzpESrJgQ0icT2KNCHBdoIfki0qyBoyLhmj8N9V1NzwpDrGKqOAjY52MPxis= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777998006; c=relaxed/simple; bh=V+ogtdUQEzr2TFT0wkxSUlELPMIfANqv25U8XJ3zxR0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=eB6baeAXFPQ5evhAp0le32u+jE8VY2TH0qvmt6m7DOYjBtnZgLuK05HPC8tEi5vDhmGaZMHzvZqEpSBUFt6r/kvJBsDifiu0Pw2E2w1BDw8qZxTbKUHOwDRKFM4mygMcXa100HNXjFf7pmAS7AGbTgrONHjBELuT7yGNClnwgCE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC42E4BA7993 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777998005; bh=V+ogtdUQEzr2TFT0wkxSUlELPMIfANqv25U8XJ3zxR0=; h=Date:Subject:To:References:From:In-Reply-To:From; b=WokAkKDzR1J22mILewYhZ926IA4a5ZjkW+/ezOfQYmGgFcrj4pqp3jQn2imX6Ad4z tfqpK5bMi9892Eko5siGjkpvzdFXNlLCdueEd66L+dFiDZMF6TxFKMA0QyGB18+v83 Nvd1jdMo/Vj5+wVkWbqH13CYggwH1PaYeX2M40/U= Received: by simark.ca (Postfix) id 8EE1D1E067; Tue, 05 May 2026 12:20:05 -0400 (EDT) Message-ID: <294bd07f-7d35-4209-a511-9b683b66f2ea@simark.ca> Date: Tue, 5 May 2026 12:20:05 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb: use correct target in notify_thread_exited() To: Markus Metzger , gdb-patches@sourceware.org References: <20260505075744.936344-1-markus.t.metzger@intel.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20260505075744.936344-1-markus.t.metzger@intel.com> Content-Type: text/plain; charset=UTF-8 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 On 2026-05-05 03:57, Markus Metzger wrote: > clean_up_just_stopped_threads_fsms() may call notify_thread_exited() in > the context of a thread from a different target. > > Switch to the thread we're notifying about to get the inferior and target > right. > > CC: Simon Marchi > --- > gdb/thread.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/gdb/thread.c b/gdb/thread.c > index c156f16377b..02ea62d524c 100644 > --- a/gdb/thread.c > +++ b/gdb/thread.c > @@ -203,6 +203,9 @@ notify_thread_exited (thread_info *t, std::optional exit_code, > { > if (!silent && print_thread_events) > { > + scoped_restore_current_thread restore_thread; > + switch_to_thread (t); Let's use: /* Switch inferior before the target calls below. */ auto restore_inf = maybe_switch_inferior (t->inf); > + > if (exit_code.has_value ()) > gdb_printf (_("[%s (id %s) exited with code %s]\n"), > target_pid_to_str (t->ptid).c_str (), I checked if any callee of the observable cared whether THREAD is the current thread, or if THREAD's inferior is the current inferior, and I don't think so. remove_threaded_breakpoints recurses into a bunch of breakpoint functions so it's difficult to be sure, but at first glance it seems fine. With the above fixed: Approved-By: Simon Marchi Simon