[compiler-rt] [asan] Switch initialization to "double-checked locking" (PR #74387)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 12:43:33 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();
----------------
vitalybuka wrote:

We will have to do something about SANITIZER_SUPPORTS_INIT_FOR_DLOPEN
I'd like to avoid dealing with that in this patch.

https://github.com/llvm/llvm-project/pull/74387


More information about the llvm-commits mailing list