From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8OE6LK3+XmFTawAAWB0awg (envelope-from ) for ; Thu, 07 Oct 2021 10:05:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 9DC1D1EE20; Thu, 7 Oct 2021 10:05:33 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DEA5E1EDDB for ; Thu, 7 Oct 2021 10:05:32 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 555143858015 for ; Thu, 7 Oct 2021 14:05:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 555143858015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633615532; bh=UIdhU2AmHkTK8gD5R8FwFopJscZcFFf0qFd8SDACYfA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gPEmRzfgN5Rkgt+8WzzS9qj3IfXnwVcIqIrEOyHCIRflyowTSrjsVG74Aa61L4nUh N1gPD4dh7CJpuBS5nyLEqTeF3aTzljwLimd+bjqhyklHpR1pFizmdoxkvic5MppofJ pUHNP9NtE1BNbSjU/D4JRpqmymSkZ487v6vXLibU= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 3A1093858C60 for ; Thu, 7 Oct 2021 14:05:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A1093858C60 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6F51C200BE for ; Thu, 7 Oct 2021 14:05:12 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5D15C13EAC for ; Thu, 7 Oct 2021 14:05:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id FLFVFZj+XmEaTQAAMHmgww (envelope-from ) for ; Thu, 07 Oct 2021 14:05:12 +0000 Date: Thu, 7 Oct 2021 16:05:11 +0200 To: gdb-patches@sourceware.org Subject: [RFC][gdb/threads] Fix FAIL in gdb.threads/current-lwp-dead.exp Message-ID: <20211007140509.GA23194@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, On openSUSE Tumbleweed, I run into: ... (gdb) continue^M Continuing.^M [New Thread 0x7ffff7cc6740 (LWP 15909)]^M [Thread 0x7ffff7cc6740 (LWP 15905) exited]^M Cannot find user-level thread for LWP 15910: generic error^M (gdb) FAIL: gdb.threads/current-lwp-dead.exp: \ continue to breakpoint: fn_return ... Debugging reveals that the error is thrown during a call to thread_from_lwp from thread_db_notice_clone. Fix this by: - wrapping the call in a generic try-catch, - handling a subsequent, similar call that causes the same error in the same way, and - handling a segfault in thread_from_lwp by not calling it with stopped argument == nullptr in thread_db_target::wait. This is all symptom handling without any analysis, but it makes the test-case pass, in the same way as it passes on openSUSE Leap 15.2: ... (gdb) continue^M Continuing.^M [New Thread 0x7ffff7cc6740 (LWP 16880)]^M [Thread 0x7ffff7cc6740 (LWP 16876) exited]^M [New LWP 16881]^M [Thread 0x7ffff7cc6740 (LWP 16880) exited]^M [Switching to LWP 16881]^M Cannot remove breakpoints because program is no longer writable.^M Further execution is probably impossible.^M ^M Thread 3 hit Breakpoint 2, fn_return (unused=) at current-lwp-dead.c:45^M 45 return 0; /* at-fn_return */^M (gdb) PASS: gdb.threads/current-lwp-dead.exp: \ continue to breakpoint: fn_return ... Tested gdb.threads/*.exp on x86_64-linux, no regressions. Any comments? Thanks, - Tom [gdb/threads] Fix FAIL in gdb.threads/current-lwp-dead.exp --- gdb/linux-thread-db.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 54e68ccd0d7..e65dce96efe 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -441,11 +441,24 @@ thread_db_notice_clone (ptid_t parent, ptid_t child) thread_info *stopped = find_thread_ptid (linux_target, parent); - thread_from_lwp (stopped, child); + try + { + thread_from_lwp (stopped, child); + } + catch (...) + { + } /* If we do not know about the main thread's pthread info yet, this would be a good time to find it. */ - thread_from_lwp (stopped, parent); + try + { + thread_from_lwp (stopped, parent); + } + catch (...) + { + } + return 1; } @@ -1424,7 +1437,9 @@ thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, return ptid; /* Fill in the thread's user-level thread id and status. */ - thread_from_lwp (find_thread_ptid (beneath, ptid), ptid); + thread_info *stopped = find_thread_ptid (beneath, ptid); + if (stopped != nullptr) + thread_from_lwp (stopped, ptid); return ptid; }