diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-09-13 11:06:08 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-09-13 11:06:08 +0200 |
commit | 526c3cf11ee9367344b6b15d669e4c3cb461a2be (patch) | |
tree | 428aa0c50880ee5001732622b0afe94ba7e113d9 /nptl/allocatestack.c | |
parent | 8af8456004edbab71f8903a60a3cae442cf6fe69 (diff) | |
download | glibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.tar.gz glibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.tar.xz glibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.zip |
nptl: Fix race between pthread_kill and thread exit (bug 12889)
A new thread exit lock and flag are introduced. They are used to detect that the thread is about to exit or has exited in __pthread_kill_internal, and the signal is not sent in this case. The test sysdeps/pthread/tst-pthread_cancel-select-loop.c is derived from a downstream test originally written by Marek Polacek. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'nptl/allocatestack.c')
-rw-r--r-- | nptl/allocatestack.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 0356993c26..fa8100719f 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -31,6 +31,7 @@ #include <futex-internal.h> #include <kernel-features.h> #include <nptl-stack.h> +#include <libc-lock.h> /* Default alignment of stack. */ #ifndef STACK_ALIGN @@ -126,6 +127,8 @@ get_cached_stack (size_t *sizep, void **memp) /* No pending event. */ result->nextevent = NULL; + result->exiting = false; + __libc_lock_init (result->exit_lock); result->tls_state = (struct tls_internal_t) { 0 }; /* Clear the DTV. */ |