Skip to content

Commit

Permalink
Fix Singleton/ThreadLocal destruction order crashes in buck dev builds
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andriigrynenko authored and facebook-github-bot-0 committed Feb 12, 2016
1 parent 1a7befd commit b017402
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions folly/Singleton.cpp
Expand Up @@ -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<void>::instance();

class SingletonVaultDestructor {
public:
~SingletonVaultDestructor() {
Expand Down

0 comments on commit b017402

Please sign in to comment.