From patchwork Tue Feb 28 18:18:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 65803 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB8D33850425 for ; Tue, 28 Feb 2023 18:19:38 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id 3C7FD3858C54 for ; Tue, 28 Feb 2023 18:19:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3C7FD3858C54 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 gimli.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id 461231A84E38 for ; Tue, 28 Feb 2023 13:18:59 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 8/9] fbsd-nat: Fix thread_alive against a running thread. Date: Tue, 28 Feb 2023 10:18:44 -0800 Message-Id: <20230228181845.99936-9-jhb@FreeBSD.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230228181845.99936-1-jhb@FreeBSD.org> References: <20230228181845.99936-1-jhb@FreeBSD.org> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Tue, 28 Feb 2023 13:18:59 -0500 (EST) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_STATUS, KHOP_HELO_FCRDNS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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 e3d83cbf908..32dd482ec3c 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -861,7 +861,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;