[PATCH] pthread_detach: add a comment about a known segfault bug.

Sam James sam@gentoo.org
Sun Nov 23 21:40:50 GMT 2025


[dropped double Carlos]

Aaron Jacobs <aaronjjacobs@gmail.com> writes:

> From: Aaron Jacobs <aaronjjacobs@gmail.com>
>
> This bug has existed for nearly a decade, so doesn't seem like it's
> likely to be fixed tomorrow. If this comment had been here yesterday it
> would have saved me many hours of debugging.

You should include a reference to the bug in the commit, but that aside,
azanella posted https://sourceware.org/bugzilla/show_bug.cgi?id=19951#c5
and asked for someone who is interested to take a look. Why don't you?

> ---
>  nptl/pthread_detach.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/nptl/pthread_detach.c b/nptl/pthread_detach.c
> index 3bbc037bdc..1e26eaf09e 100644
> --- a/nptl/pthread_detach.c
> +++ b/nptl/pthread_detach.c
> @@ -44,7 +44,9 @@ ___pthread_detach (pthread_t th)
>      }
>    else
>      /* Check whether the thread terminated meanwhile.  In this case we
> -       will just free the TCB.  */
> +       will just free the TCB.  Note using pd after giving up ownership above is
> +       incorrect, and this code may segfault. See
> +       https://sourceware.org/bugzilla/show_bug.cgi?id=19951. */
>      if ((pd->cancelhandling & EXITING_BITMASK) != 0)
>        /* Note that the code in __free_tcb makes sure each thread
>  	 control block is freed only once.  */


More information about the Libc-alpha mailing list