[compiler-rt] [asan] Switch initialization to "double-checked locking" (PR #74387)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 23:55:04 PST 2023
================
@@ -515,22 +511,27 @@ static void AsanInitInternal() {
VReport(1, "AddressSanitizer Init done\n");
WaitForDebugger(flags()->sleep_after_init, "after init");
+
+ return true;
}
// Initialize as requested from some part of ASan runtime library (interceptors,
// allocator, etc).
void AsanInitFromRtl() {
- CHECK(!AsanInitIsRunning());
- if (UNLIKELY(!AsanInited()))
- AsanInitInternal();
+ if (LIKELY(AsanInited()))
+ return;
+ SpinMutexLock lock(&asan_inited_mutex);
+ AsanInitInternal();
}
bool TryAsanInitFromRtl() {
- if (UNLIKELY(AsanInitIsRunning()))
+ if (LIKELY(AsanInited()))
+ return true;
+ if (!asan_inited_mutex.TryLock())
----------------
vitalybuka wrote:
Thanks. No, unintentional. I missed this one.
I'll try to split them.
https://github.com/llvm/llvm-project/pull/74387
More information about the llvm-commits
mailing list