From 7235d2011dbd7efaf67489d3a827ce006f2399e7 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Tue, 5 Jul 2016 11:34:29 -0700 Subject: [PATCH] Disable PthreadKeyUnregister on iOS and MSVC Summary: ~PthreadKeyUnregister logic is not safe if we can't guarantee that it has the maximum pririty (i.e. is the last to be run on shutdown). Reviewed By: ericniebler Differential Revision: D3517589 fbshipit-source-id: 3340e2e19cf52973ee677288bc4ac6105f3f2543 --- folly/detail/ThreadLocalDetail.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/folly/detail/ThreadLocalDetail.h b/folly/detail/ThreadLocalDetail.h index 3bcfbfa2..275271f4 100644 --- a/folly/detail/ThreadLocalDetail.h +++ b/folly/detail/ThreadLocalDetail.h @@ -172,10 +172,14 @@ class PthreadKeyUnregister { static constexpr size_t kMaxKeys = 1UL << 16; ~PthreadKeyUnregister() { + // If static constructor priorities are not supported then + // ~PthreadKeyUnregister logic is not safe. +#if !defined(__APPLE__) && !defined(_MSC_VER) MSLGuard lg(lock_); while (size_) { pthread_key_delete(keys_[--size_]); } +#endif } static void registerKey(pthread_key_t key) { -- 2.34.1