From: Pedro Alves <palves@redhat.com>
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 [thread overview]
Message-ID: <1425671886-7798-5-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1425671886-7798-1-git-send-email-palves@redhat.com>
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 <palves@redhat.com>
* 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
next prev parent reply other threads:[~2015-03-06 19:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 19:58 [PATCH 0/6] Fix problems if inferior disappears while being debugged Pedro Alves
2015-03-06 19:58 ` [PATCH 1/6] Move throw_perror_with_name to common/ Pedro Alves
2015-03-06 19:58 ` [PATCH 2/6] Introduce throw_ptrace_error Pedro Alves
2015-03-06 21:04 ` Mark Kettenis
2015-03-06 21:40 ` Pedro Alves
2015-03-08 20:30 ` Mark Kettenis
2015-03-08 21:48 ` Pedro Alves
2015-03-10 14:53 ` Mark Kettenis
2015-03-11 15:44 ` Pedro Alves
2015-03-19 17:33 ` [pushed] Fix race exposed by gdb.threads/killed.exp (Re: [PATCH 2/6] Introduce throw_ptrace_error) Pedro Alves
2015-03-06 19:58 ` [PATCH 5/6] gdbserver/Linux: internal error when killing a process that is already gone Pedro Alves
2015-03-06 19:58 ` Pedro Alves [this message]
2015-03-19 12:37 ` [pushed] native/Linux: internal error if resume is short-circuited (Re: [PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint) Pedro Alves
2015-03-19 12:49 ` [pushed] gdbserver/Linux: unbreak thread event randomization (Re: [pushed] native/Linux: internal error if resume is short-circuited) Pedro Alves
2015-03-19 16:14 ` [PATCH] gdbserver/Linux: Unbreak non-stop (Re: [pushed] gdbserver/Linux: unbreak thread event randomization) Pedro Alves
2015-03-19 16:54 ` [pushed] " Pedro Alves
2015-03-06 19:58 ` [PATCH 3/6] Fix race exposed by gdb.threads/killed.exp Pedro Alves
2015-03-19 17:39 ` Pedro Alves
2015-03-06 20:27 ` [PATCH 6/6] Add test that exercises the inferior being killed while stopped under GDB Pedro Alves
2015-07-14 10:22 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425671886-7798-5-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox