From 04c44d92c941da928d23b91aa1976f9844a0b3c1 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 24 Mar 2021 02:32:35 -0400 Subject: [PATCH] Remove OPENSSL_DANGEROUS_RELEASE_PTHREAD_KEY build flag. It's now a year past the February 2020 deadline for removing it. Judging from b/72831885, it looks like the root cause was addressed. Change-Id: I8c8b358ef4f4146b41aab2a7163c000fa7306025 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/46407 Reviewed-by: Adam Langley --- crypto/thread_pthread.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/crypto/thread_pthread.c b/crypto/thread_pthread.c index 2cb100081..e873d0490 100644 --- a/crypto/thread_pthread.c +++ b/crypto/thread_pthread.c @@ -127,34 +127,6 @@ static pthread_once_t g_thread_local_init_once = PTHREAD_ONCE_INIT; static pthread_key_t g_thread_local_key; static int g_thread_local_key_created = 0; -// OPENSSL_DANGEROUS_RELEASE_PTHREAD_KEY can be defined to cause -// |pthread_key_delete| to be called in a destructor function. This can be -// useful for programs that dlclose BoringSSL. -// -// Note that dlclose()ing BoringSSL is not supported and will leak memory: -// thread-local values will be leaked as well as anything initialised via a -// once. The |pthread_key_t| is destroyed because they run out very quickly, -// while the other leaks are slow, and this allows code that happens to use -// dlclose() despite all the problems to continue functioning. -// -// This is marked "dangerous" because it can cause multi-threaded processes to -// crash (even if they don't use dlclose): if the destructor runs while other -// threads are still executing then they may end up using an invalid key to -// access thread-local variables. -// -// This may be removed after February 2020. -#if defined(OPENSSL_DANGEROUS_RELEASE_PTHREAD_KEY) && \ - (defined(__GNUC__) || defined(__clang__)) -// thread_key_destructor is called when the library is unloaded with dlclose. -static void thread_key_destructor(void) __attribute__((destructor, unused)); -static void thread_key_destructor(void) { - if (g_thread_local_key_created) { - g_thread_local_key_created = 0; - pthread_key_delete(g_thread_local_key); - } -} -#endif - static void thread_local_init(void) { g_thread_local_key_created = pthread_key_create(&g_thread_local_key, thread_local_destructor) == 0;