From: Andrii Grynenko Date: Fri, 12 Feb 2016 18:22:25 +0000 (-0800) Subject: Fix Singleton/ThreadLocal destruction order crashes in buck dev builds X-Git-Tag: deprecate-dynamic-initializer~75 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b01740268c9cba59c93741e8028afafe67a2d170;p=folly.git Fix Singleton/ThreadLocal destruction order crashes in buck dev builds Summary: This adds a folly::Singleton->folly::ThreadLocal dependency to make sure folly::ThreadLocal is always loaded first. Otherwise PthreadKeyUnregister singleton is created after folly::Singleton storage, even though it has higher priority. Reviewed By: andrewjcg Differential Revision: D2931170 fb-gh-sync-id: 36392d76e98201f2b4416b4bbef451d6c0e8c69d shipit-source-id: 36392d76e98201f2b4416b4bbef451d6c0e8c69d --- diff --git a/folly/Singleton.cpp b/folly/Singleton.cpp index 66321bfd..1cf9c4d9 100644 --- a/folly/Singleton.cpp +++ b/folly/Singleton.cpp @@ -213,6 +213,10 @@ void SingletonVault::reenableInstances() { } void SingletonVault::scheduleDestroyInstances() { + // Add a dependency on folly::ThreadLocal to make sure all its static + // singletons are initalized first. + threadlocal_detail::StaticMeta::instance(); + class SingletonVaultDestructor { public: ~SingletonVaultDestructor() {