From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53507 invoked by alias); 6 Mar 2015 19:58:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 53425 invoked by uid 89); 6 Mar 2015 19:58:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 Mar 2015 19:58:14 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t26JwCPw007245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 6 Mar 2015 14:58:12 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t26Jw60o024787 for ; Fri, 6 Mar 2015 14:58:12 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint Date: Fri, 06 Mar 2015 19:58:00 -0000 Message-Id: <1425671886-7798-5-git-send-email-palves@redhat.com> In-Reply-To: <1425671886-7798-1-git-send-email-palves@redhat.com> References: <1425671886-7798-1-git-send-email-palves@redhat.com> X-SW-Source: 2015-03/txt/msg00180.txt.bz2 If the inferior disappears just after it was stopped at a breakpoint, GDB internal errors on next resume: Executing on target: kill -9 11605 (timeout = 300) spawn -ignore SIGHUP kill -9 11605 continue Continuing. /home/pedro/gdb/mygit/src/gdb/linux-nat.c:2590: internal-error: status_callback: Assertion `lp->status != 0' failed. This is because the thread had stopped for a breakpoint, and had already reported the event, so its ->status flag was cleared. The lwp's stopped, etc., flags should only be cleared when we're sure the LWP was successfully resumed (see PR gdb/15713, git 8817a6f2). So the next resume hits an ESRCH error which throws before those flags are cleared. GDB core prints the error, and ends up calling target_wait to poll remaining events. We then trip on the assertion. Fix this by bailing out earlier. GDBserver is already doing this. A follow up patch will add a test that exercises this (gdb.base/killed-outside.exp). gdb/ChangeLog: 2015-03-06 Pedro Alves * linux-nat.c (status_callback): Return early if the LWP has no status pending. --- gdb/linux-nat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 6bb62fd..68fd4bf 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2574,6 +2574,9 @@ status_callback (struct lwp_info *lp, void *data) if (!lp->resumed) return 0; + if (!lwp_status_pending_p (lp)) + return 0; + if (lp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT || lp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT) { @@ -2582,8 +2585,6 @@ status_callback (struct lwp_info *lp, void *data) CORE_ADDR pc; int discard = 0; - gdb_assert (lp->status != 0); - pc = regcache_read_pc (regcache); if (pc != lp->stop_pc) @@ -2621,10 +2622,9 @@ status_callback (struct lwp_info *lp, void *data) linux_resume_one_lwp (lp, lp->step, GDB_SIGNAL_0); return 0; } - return 1; } - return lwp_status_pending_p (lp); + return 1; } /* Return non-zero if LP isn't stopped. */ -- 1.9.3