Skip to content
Snippets Groups Projects
Commit 81291381 authored by Richard Linden's avatar Richard Linden
Browse files

SH-4080 WIP interesting: random crash on Mac

fixed Mac crash related to non-reentrant singleton constructor
parent 1a01542e
No related branches found
No related tags found
No related merge requests found
...@@ -83,8 +83,10 @@ class LLSingleton : private boost::noncopyable ...@@ -83,8 +83,10 @@ class LLSingleton : private boost::noncopyable
void construct() void construct()
{ {
sReentrantConstructorGuard = true;
mSingletonInstance = new DERIVED_TYPE(); mSingletonInstance = new DERIVED_TYPE();
mInitState = INITIALIZING; mInitState = INITIALIZING;
sReentrantConstructorGuard = false;
} }
~SingletonInstanceData() ~SingletonInstanceData()
...@@ -174,7 +176,7 @@ class LLSingleton : private boost::noncopyable ...@@ -174,7 +176,7 @@ class LLSingleton : private boost::noncopyable
// Use this to avoid accessing singletons before the can safely be constructed // Use this to avoid accessing singletons before the can safely be constructed
static bool instanceExists() static bool instanceExists()
{ {
return getSingletonData().mInitState == INITIALIZED; return sReentrantConstructorGuard || getSingletonData().mInitState == INITIALIZED;
} }
// Has this singleton already been deleted? // Has this singleton already been deleted?
...@@ -194,6 +196,11 @@ class LLSingleton : private boost::noncopyable ...@@ -194,6 +196,11 @@ class LLSingleton : private boost::noncopyable
} }
virtual void initSingleton() {} virtual void initSingleton() {}
static bool sReentrantConstructorGuard;
}; };
template<typename T>
bool LLSingleton<T>::sReentrantConstructorGuard = false;
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment