[PATCH 0/5] GNU/Linux, fix attach races/problems

Pedro Alves palves@redhat.com
Fri Jan 9 12:03:00 GMT 2015


On 12/16/2014 04:53 PM, Pedro Alves wrote:
> Investigating an "attach" bug seemingly caused by a race, related to
> the fact that on Linux we have to attach to each thread individually,
> I decided to write a test that stresses that aspect of attach.  The
> test constantly spawns short-lived threads, and has GDB attach, debug
> a little, detach, attach, rinse/repeat a few times.
> 
> That actually exposed a set of issues, both in GDB and in
> glibc/libthread_db.
> 
> One is that the test defeats the current heuristics in place: we still
> fail to attach to some threads sometimes, if the program spawns them
> quickly enough.  This is fixed by fetching the list of LWPs to attach
> to from /proc instead of relying on libthread_db for that.
> 
> Another is that some times we'd try to attach to a bogus lwp with
> PID==-1, and do a dangerous waitpid, potentially eating an event by
> mistake and breaking the debug session as result.
> 
> Yet another is a nasty libthread_db event reporting mechanism race
> related to detaching from the inferior just while a thread is
> reporting an event, resulting in a subsequent attach session tripping
> on broken libthread_db events.  We work around this by no longer using
> libthread_db for thread event creation/death reporting, which is good
> on its own, for being much more robust and efficient.
> 
> I've filed a couple glibc bugs as result of all this:
> 
>  Bug 17705 - nptl_db: stale thread create/death events if debugger detaches
>  https://sourceware.org/bugzilla/show_bug.cgi?id=17705
> 
>  Bug 17707 - nptl_db: terminated and joined threads
>  https://sourceware.org/bugzilla/show_bug.cgi?id=17707
> 
> The series fixes the GDB issues and at the same time works around the
> glibc issues.
> 
> Tested on x86_64 Fedora 20, native and gdbserver.
> 
> Comments?

I've pushed this in now.

Thanks,
Pedro Alves



More information about the Gdb-patches mailing list