From: Andrii Grynenko Date: Tue, 5 Jul 2016 18:34:29 +0000 (-0700) Subject: Disable PthreadKeyUnregister on iOS and MSVC X-Git-Tag: 2016.07.26~78 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7235d2011dbd7efaf67489d3a827ce006f2399e7;p=folly.git 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 --- 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) {