From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id AE0383857C51 for ; Mon, 17 Jul 2023 19:21:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE0383857C51 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.com (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id ED53F1A84E25 for ; Mon, 17 Jul 2023 15:20:57 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v2 5/8] fbsd-nat: Fix thread_alive against a running thread. Date: Mon, 17 Jul 2023 12:20:36 -0700 Message-Id: <20230717192039.13976-6-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230717192039.13976-1-jhb@FreeBSD.org> References: <20230717192039.13976-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Mon, 17 Jul 2023 15:20:58 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: FreeBSD's ptrace fails requests with EBUSY against a running process. Report that the thread is alive instead of dead if ptrace fails with EBUSY. This fixes an internal error in the gdb.threads/detach-step-over.exp test where one process was detached while a thread in a second process was being stepped. The core incorrectly assumed the stepping thread had vanished and discarded the pending stepping state. When the thread later reported a SIGTRAP from completing the step, this triggered an assertion. --- gdb/fbsd-nat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index ed69cb33e93..6ce77c5cd16 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -839,7 +839,13 @@ fbsd_nat_target::thread_alive (ptid_t ptid) if (ptrace (PT_LWPINFO, ptid.lwp (), (caddr_t) &pl, sizeof pl) == -1) - return false; + { + /* EBUSY means the associated process is running which means + the LWP does exist and belongs to a running process. */ + if (errno == EBUSY) + return true; + return false; + } #ifdef PL_FLAG_EXITED if (pl.pl_flags & PL_FLAG_EXITED) return false; -- 2.40.0