Disable PthreadKeyUnregister on iOS and MSVC
authorAndrii Grynenko <andrii@fb.com>
Tue, 5 Jul 2016 18:34:29 +0000 (11:34 -0700)
committerFacebook Github Bot 5 <facebook-github-bot-5-bot@fb.com>
Tue, 5 Jul 2016 18:38:41 +0000 (11:38 -0700)
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

index 3bcfbfa24b6a451e56ac1c318c0c26119e017482..275271f49cdd99c45146f2e0780f4033c1dfdf37 100644 (file)
@@ -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) {