aboutsummaryrefslogtreecommitdiff
path: root/nptl/descr.h
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-09-13 11:06:08 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-09-13 11:06:08 +0200
commit526c3cf11ee9367344b6b15d669e4c3cb461a2be (patch)
tree428aa0c50880ee5001732622b0afe94ba7e113d9 /nptl/descr.h
parent8af8456004edbab71f8903a60a3cae442cf6fe69 (diff)
downloadglibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.zip
glibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.tar.gz
glibc-526c3cf11ee9367344b6b15d669e4c3cb461a2be.tar.bz2
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/descr.h')
-rw-r--r--nptl/descr.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/nptl/descr.h b/nptl/descr.h
index e1c8831..41ee56f 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -395,6 +395,12 @@ struct pthread
PTHREAD_CANCEL_ASYNCHRONOUS). */
unsigned char canceltype;
+ /* Used in __pthread_kill_internal to detected a thread that has
+ exited or is about to exit. exit_lock must only be acquired
+ after blocking signals. */
+ bool exiting;
+ int exit_lock; /* A low-level lock (for use with __libc_lock_init etc). */
+
/* Used on strsignal. */
struct tls_internal_t tls_state;