Re: Hanging threads with pthread_detach and gdb

From: Lin Ming
Date: Fri Aug 19 2011 - 08:10:22 EST


On Fri, 2011-08-19 at 18:28 +0800, Pedro Alves wrote:
> On Friday 19 August 2011 09:54:43, Lin Ming wrote:
> > =====
> > gdb wait for pid=2431
> > gdb is going to sleep ...
> > gdb children list:
> > pid=2431, exit_state=16, exit_signal=17
> > gdb ptrace list:
> > pid=2436, exit_state=16, exit_signal=-1
> > pid=2431, exit_state=16, exit_signal=17
> > =====
> >
> > exit_state 16 is EXIT_ZOMBIE state.
> > pid 2431 is the thread group leader.
> > pid 2436 is the thread group member(other members have been removed).
> >
> > gdb is waiting the group leader, but it fails because the group is not
> > empty. Then gdb goes to sleep.
> >
> > At this moment, all threads have gone into EXIT_ZOMBIE state.
> > So no thread can wake up gdb anymore.
> >
> > That's why gdb hangs.
> >
> > I'm not familiar with pthread semantics.
> > Is this a problem need to be fixed?
> >
>
> Yeah, it's an ugly ptrace quirk. waitpid'ing the exited
> tg leader hangs if there are other threads in the group,
> even if they're zombies.
>
> I believe this is fixed / worked around mainline GDB:
>
> http://sourceware.org/bugzilla/show_bug.cgi?id=10970
> http://sourceware.org/bugzilla/show_bug.cgi?id=12702
> http://sourceware.org/ml/gdb-patches/2011-05/msg00401.html
>
> Though it'd be nice not to need the workaround...

Thanks for the info.

I still wonder if this is fixable in kernel.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/