This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix for internal-error: linux_nat_post_attach_wait: Assertion `pid == new_pid && WIFSTOPPED (status)' failed.
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: gdb-patches at sourceware dot org
- Cc: ppluzhnikov at google dot com, "Pedro Alves" <pedro at codesourcery dot com>
- Date: Tue, 13 Oct 2009 11:41:20 -0700 (PDT)
- Subject: [patch] Fix for internal-error: linux_nat_post_attach_wait: Assertion `pid == new_pid && WIFSTOPPED (status)' failed.
Greetings,
Using test case from http://sourceware.org/bugzilla/show_bug.cgi?id=10757,
Pedro noticed, and I reproduced (this happens rarely):
warning: Can't attach LWP 15338: No such process
../../src/gdb/linux-nat.c:1341: internal-error: linux_nat_post_attach_wait: Assertion `pid == new_pid && WIFSTOPPED (status)' failed.
When assertion fails, status == 0.
Here is a proposed fix.
Thanks,
--
Paul Pluzhnikov
2009-10-13 Paul Pluzhnikov <ppluzhnikov@google.com>
* linux-nat.c (linux_nat_post_attach_wait): Adjust assert.
Index: linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.151
diff -u -p -u -r1.151 linux-nat.c
--- linux-nat.c 9 Oct 2009 01:57:12 -0000 1.151
+++ linux-nat.c 13 Oct 2009 18:18:37 -0000
@@ -1338,16 +1338,22 @@ linux_nat_post_attach_wait (ptid_t ptid,
*cloned = 1;
}
- gdb_assert (pid == new_pid && WIFSTOPPED (status));
+ gdb_assert (pid == new_pid);
- if (WSTOPSIG (status) != SIGSTOP)
+ if (WIFSTOPPED (status))
{
- *signalled = 1;
- if (debug_linux_nat)
- fprintf_unfiltered (gdb_stdlog,
- "LNPAW: Received %s after attaching\n",
- status_to_str (status));
+ if (WSTOPSIG (status) != SIGSTOP)
+ {
+ *signalled = 1;
+ if (debug_linux_nat)
+ fprintf_unfiltered (gdb_stdlog,
+ "LNPAW: Received %s after attaching\n",
+ status_to_str (status));
+ }
}
+ else
+ /* We could have been notified about LWP exit. */
+ gdb_assert (*cloned);
return status;
}