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
static constexpr size_t kMaxKeys = 1UL << 16;
~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_]);
}
MSLGuard lg(lock_);
while (size_) {
pthread_key_delete(keys_[--size_]);
}
}
static void registerKey(pthread_key_t key) {
}
static void registerKey(pthread_key_t key) {