[patch] Fix for internal-error: linux_nat_post_attach_wait: Assertion `pid == new_pid && WIFSTOPPED (status)' failed.

Paul Pluzhnikov
2009-10-13T18:41:35Z

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;
}