From: Andrii Grynenko Date: Thu, 22 Jan 2015 19:07:08 +0000 (-0800) Subject: Fix ASAN failures in OBCClient X-Git-Tag: v0.23.0~30 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7ea7f87039a235088aaca91b03ca3e12175c52a5;p=folly.git Fix ASAN failures in OBCClient Summary: This also adds a dependency from all folly::Singletons on RequestContext. Better fix would probaly be to switch RequestContext to be managed by folly::Singleton, however that would require us to switch all singletons which use it to be folly::Singletons too. Facebook: Making sure we initialize SR singletons when OBCClient singleton is created, so that SR is destoyed after OBCClient. Test Plan: fbconfig -r --sanitize=address --platform-all=gcc-4.8.1-glibc-2.17 dragon/ fbmake runtests Reviewed By: meyering@fb.com, davejwatson@fb.com Subscribers: trunkagent, folly-diffs@, meyering FB internal diff: D1796847 Tasks: 5986816 Signature: t1:1796847:1421954531:e9ec177d5289a33c12fe0947426d89963c8e262c --- diff --git a/folly/experimental/Singleton.cpp b/folly/experimental/Singleton.cpp index 68f531a6..f77c5c52 100644 --- a/folly/experimental/Singleton.cpp +++ b/folly/experimental/Singleton.cpp @@ -81,6 +81,8 @@ SingletonVault* SingletonVault::singleton() { } void SingletonVault::scheduleDestroyInstances() { + RequestContext::getStaticContext(); + class SingletonVaultDestructor { public: ~SingletonVaultDestructor() { diff --git a/folly/experimental/Singleton.h b/folly/experimental/Singleton.h index 54eb74b5..11ff198f 100644 --- a/folly/experimental/Singleton.h +++ b/folly/experimental/Singleton.h @@ -96,6 +96,7 @@ #include #include #include +#include #include #include @@ -326,6 +327,7 @@ class SingletonVault { // Mark registration is complete; no more singletons can be // registered at this point. void registrationComplete() { + RequestContext::getStaticContext(); std::atexit([](){ SingletonVault::singleton()->destroyInstances(); }); RWSpinLock::WriteHolder wh(&stateMutex_);