forked from OSchip/llvm-project
Make gCrashRecoveryEnabled thread local
If context is enabled/disabled and queried concurrently then this results in a data race/TSAN failure with RunSafely (where boolean variable was not locked). There doesn't seem to be a reasonable way to enable threads that enable and disable recovery in parallel (without also keeping gCrashRecoveryEnabled's lock held during Fn execution which seems undesirable). This makes enable checking if enabled thread local and consistent with other thread local usage of crash context here. Differential Revision: https://reviews.llvm.org/D93907
This commit is contained in:
parent
1cb47a063e
commit
5e77ea04f2
|
@ -84,8 +84,7 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static ManagedStatic<std::mutex> gCrashRecoveryContextMutex;
|
||||
static bool gCrashRecoveryEnabled = false;
|
||||
static LLVM_THREAD_LOCAL bool gCrashRecoveryEnabled = false;
|
||||
|
||||
static ManagedStatic<sys::ThreadLocal<const CrashRecoveryContext>>
|
||||
tlIsRecoveringFromCrash;
|
||||
|
@ -136,8 +135,6 @@ CrashRecoveryContext *CrashRecoveryContext::GetCurrent() {
|
|||
}
|
||||
|
||||
void CrashRecoveryContext::Enable() {
|
||||
std::lock_guard<std::mutex> L(*gCrashRecoveryContextMutex);
|
||||
// FIXME: Shouldn't this be a refcount or something?
|
||||
if (gCrashRecoveryEnabled)
|
||||
return;
|
||||
gCrashRecoveryEnabled = true;
|
||||
|
@ -145,7 +142,6 @@ void CrashRecoveryContext::Enable() {
|
|||
}
|
||||
|
||||
void CrashRecoveryContext::Disable() {
|
||||
std::lock_guard<std::mutex> L(*gCrashRecoveryContextMutex);
|
||||
if (!gCrashRecoveryEnabled)
|
||||
return;
|
||||
gCrashRecoveryEnabled = false;
|
||||
|
|
Loading…
Reference in New Issue