From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id jbNFEw5LrGpWFhgAWB0awg (envelope-from ) for ; Thu, 17 Sep 2026 16:18:22 -0400 Received: by simark.ca (Postfix, from userid 112) id 355261E06A; Thu, 17 Sep 2026 16:18:22 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 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 9DF1E1E051 for ; Thu, 17 Sep 2026 16:18:21 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1F104BAE7FD for ; Thu, 17 Sep 2026 20:18:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1F104BAE7FD Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 263F04BA2E1F for ; Thu, 17 Sep 2026 20:17:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 263F04BA2E1F Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 263F04BA2E1F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789676278; cv=none; b=ZsWZ/BJ9D03OztIVqjrO+zTuDOVtUb14o8feLEsxJw+NNoa4hunHvm8mB+fTnB5JX1F3VJmsOGdB6NdmsM5fAsjoKMw+NeK5VhaYxPlzLT/up/Y414o0O2PiEwWbEf4kiSMpOFoPp7Bb0VSu1e5zbgQlBHulFgKnzmnUz9aMlrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789676278; c=relaxed/simple; bh=gpw0+2mO6HVv6iF5kAhaPQ4PWX2Te7EnU0HKR8G+wMI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cWQwwaSWzWaeIXgWe9kkGZSvLUL9Y4j0mEdLcGmsgddOVqtVul2iPUgoSiJLrGGUo4bMgnG+fvV0eKk5nWdSwTGASI2Ea1vOY7oPF7M5sKjxyiUFEy+5XjROzeSY40RuvBir3eNAApkIE2FY5feawtXVWeFjcVJuly8hE60yyNw= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 263F04BA2E1F Received: by simark.ca (Postfix) id 4F9921E051; Thu, 17 Sep 2026 16:17:56 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb: don't return an exited thread from any_non_exited_thread_of_inferior Date: Thu, 17 Sep 2026 16:16:57 -0400 Message-ID: <20260917201755.589524-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 any_non_exited_thread_of_inferior prefers to return the selected thread: /* Prefer the current thread, if there's one. */ if (inf == current_inferior () && inferior_ptid != null_ptid) return inferior_thread (); ... but the selected thread can be an exited thread. This can happen in non-stop when the selected thread exits, in which case it is kept around but marked as exited (see thread_info::deletable). Check the current thread's state before returning it, and fall through to the existing loop otherwise. Note that we also have any_live_thread_of_inferior, which is similar but differs in subtle ways. We should probably check if we can merge them at some point. Change-Id: I620ee200037c6a3fd3d59b96f16750d6b962c724 --- gdb/thread.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/thread.c b/gdb/thread.c index 0f86f6efe380..e14254619e34 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -670,9 +670,13 @@ any_non_exited_thread_of_inferior (inferior *inf) { gdb_assert (inf->pid != 0); - /* Prefer the current thread, if there's one. */ + /* Prefer the current thread, if there's one and it hasn't exited. */ if (inf == current_inferior () && inferior_ptid != null_ptid) - return inferior_thread (); + { + if (thread_info *curr_thr = inferior_thread (); + curr_thr->state () != THREAD_EXITED) + return curr_thr; + } for (thread_info &tp : inf->non_exited_threads ()) return &tp; base-commit: 0595410d007e5f628e14717cd268e557e166675f -- 2.55.0