This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/6] native/Linux: internal error if inferior disappears after stopped by breakpoint

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
 /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

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.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]