about summary refs log tree commit diff
path: root/sysdeps/htl
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-14 00:15:13 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-02-14 19:29:02 +0100
commit315c9e794a5fb8f9672081dbd7493b5fd036ab05 (patch)
treefbcefd907c86a793e7668c6581c370a8502efc03 /sysdeps/htl
parent0fb8800029d230b3711bf722b2a47db92d0e273f (diff)
downloadglibc-315c9e794a5fb8f9672081dbd7493b5fd036ab05.tar.gz
glibc-315c9e794a5fb8f9672081dbd7493b5fd036ab05.tar.xz
glibc-315c9e794a5fb8f9672081dbd7493b5fd036ab05.zip
htl: Make pthread_[gs]etspecific not check for key validity
Since __pthread_key_create might be concurrently reallocating the
__pthread_key_destructors array, it's not safe to access it without the
mutex held. Posix explicitly says we are allowed to prefer performance
over error detection.
Diffstat (limited to 'sysdeps/htl')
-rw-r--r--sysdeps/htl/pt-getspecific.c3
-rw-r--r--sysdeps/htl/pt-setspecific.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/sysdeps/htl/pt-getspecific.c b/sysdeps/htl/pt-getspecific.c
index af1161206a..a9dfd8a775 100644
--- a/sysdeps/htl/pt-getspecific.c
+++ b/sysdeps/htl/pt-getspecific.c
@@ -25,8 +25,7 @@ __pthread_getspecific (pthread_key_t key)
 {
   struct __pthread *self;
 
-  if (key < 0 || key >= __pthread_key_count
-      || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+  if (key < 0 || key >= __pthread_key_count)
     return NULL;
 
   self = _pthread_self ();
diff --git a/sysdeps/htl/pt-setspecific.c b/sysdeps/htl/pt-setspecific.c
index 982d25d012..d201416d5d 100644
--- a/sysdeps/htl/pt-setspecific.c
+++ b/sysdeps/htl/pt-setspecific.c
@@ -25,8 +25,7 @@ __pthread_setspecific (pthread_key_t key, const void *value)
 {
   struct __pthread *self = _pthread_self ();
 
-  if (key < 0 || key >= __pthread_key_count
-      || __pthread_key_destructors[key] == PTHREAD_KEY_INVALID)
+  if (key < 0 || key >= __pthread_key_count)
     return EINVAL;
 
   if (key >= self->thread_specifics_size)