[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 00:56:42 PST 2023
================
@@ -408,9 +406,8 @@ static void AsanInitInternal() {
// Stop performing init at this point if we are being loaded via
// dlopen() and the platform supports it.
if (SANITIZER_SUPPORTS_INIT_FOR_DLOPEN && UNLIKELY(HandleDlopenInit())) {
- SetAsanInitIsRunning(0);
VReport(1, "AddressSanitizer init is being performed for dlopen().\n");
- return;
+ return false;
----------------
vitalybuka wrote:
To clarify
Before the patch
* `asan_inited = 0, asan_init_is_running = 0`: `__asan_handle_no_return` proceeds but likely going to crash, e.g. on [`llvm-project/compiler-rt/lib/asan/asan_poisoning.cpp:41`](https://github.com/llvm/llvm-project/blob/43455a2f0d3cdcd8dc46c4fbdebf4e655b26c2f2/compiler-rt/lib/asan/asan_poisoning.cpp#L41)
So we don't see this case in practice.
* `asan_inited = 0, asan_init_is_running = 1`: `__asan_handle_no_return` returns doing nothing
* `asan_inited = 1, asan_init_is_running = 0`: `__asan_handle_no_return` works as expected
After the patch:
* `!AsanInited()`: `__asan_handle_no_return` return doing noting
* `AsanInited()`: `__asan_handle_no_return` works as expected
https://github.com/llvm/llvm-project/pull/74387
More information about the llvm-commits
mailing list