This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFH: failed assert debugging threaded+fork program over gdbserver
- From: Don Breazeal <donb at codesourcery dot com>
- To: Joel Brobecker <brobecker at adacore dot com>, <gdb-patches at sourceware dot org>
- Date: Thu, 12 May 2016 10:42:04 -0700
- Subject: Re: RFH: failed assert debugging threaded+fork program over gdbserver
- Authentication-results: sourceware.org; auth=none
- References: <20160512171650 dot GC26324 at adacore dot com>
On 5/12/2016 10:16 AM, Joel Brobecker wrote:
> Hello,
>
> I have noticed the following problem, when debugging a program which
> uses both threads and fork. The program is attached in copy, and
> it was compiled by simply doing:
>
> % gnatmake -g a_test
>
> The issue appears only randomly, but it seems to show up fairly
> reliably when using certain versions of GNU/Linux such as RHES7,
> or WRSLinux. I also see it on Ubuntu, but less reliably. Here is
> what I have found, debugging on WRSLinux (we set it up as a cross,
> but it should be the same with native GNU/Linux distros):
>
> % gdb a_test
> (gdb) break a_test.adb:30
> (gdb) break a_test.adb:39
> (gdb) target remote my_board:4444
> (gdb) continue
> Continuing.
> [...]
> [New Thread 866.868]
> [New Thread 866.869]
> [New Thread 870.870]
> /[...]/gdb/thread.c:89: internal-error: thread_info* inferior_thread(): Assertion `tp' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)
>
> The error happens because GDBserver returns a list of threads
> to GDB where a new thread as a different PID (870 in the case
> above, instead of 866).
Hi Joel,
This is not supposed to happen. In remote.c:remote_update_thread_list
there is a call to remove_new_fork_children that is explicitly supposed
to prevent this scenario. The new fork child thread should be deleted
from the thread list ("context") before we call remote_notice_new_inferior.
We don't want the remote to report new threads related to the fork child
until after we have handled the fork using infrun.c:follow_fork. (Note:
it looks like the function comment for remove_new_fork_children is
stale, since there are scenarios other than being stopped at a fork
catchpoint where this can occur.)
> Any advice on how I should be fixing the issue?
It looks like there is a case that remove_new_fork_children isn't
handling correctly with your test+target(s). I'd start there to find out
how the new thread is getting through.
Thanks
--Don