Commit 7ea7f870 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by woo

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
parent 72153cdf
...@@ -81,6 +81,8 @@ SingletonVault* SingletonVault::singleton() { ...@@ -81,6 +81,8 @@ SingletonVault* SingletonVault::singleton() {
} }
void SingletonVault::scheduleDestroyInstances() { void SingletonVault::scheduleDestroyInstances() {
RequestContext::getStaticContext();
class SingletonVaultDestructor { class SingletonVaultDestructor {
public: public:
~SingletonVaultDestructor() { ~SingletonVaultDestructor() {
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
#include <folly/Hash.h> #include <folly/Hash.h>
#include <folly/Memory.h> #include <folly/Memory.h>
#include <folly/RWSpinLock.h> #include <folly/RWSpinLock.h>
#include <folly/io/async/Request.h>
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
...@@ -326,6 +327,7 @@ class SingletonVault { ...@@ -326,6 +327,7 @@ class SingletonVault {
// Mark registration is complete; no more singletons can be // Mark registration is complete; no more singletons can be
// registered at this point. // registered at this point.
void registrationComplete() { void registrationComplete() {
RequestContext::getStaticContext();
std::atexit([](){ SingletonVault::singleton()->destroyInstances(); }); std::atexit([](){ SingletonVault::singleton()->destroyInstances(); });
RWSpinLock::WriteHolder wh(&stateMutex_); RWSpinLock::WriteHolder wh(&stateMutex_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment