Skip to content

Commit 249c313

Browse files
committed
[compiler-rt][asan] Fix for flaky asan check
This fixes #87324. We haven't been able to come up with a minimal reproducer but we can reliabely avoid this failure with the following fix. Prior to the GetGlobalLowLevelAllocator change, the old LowLevelAllocator aquired a lock associated with it preventing that specific allocator from being accessed at the same time by many threads. With the GetGlobalLowLevelAllocator change, I had accidentally replaced it but not taken into account the lock, so we can have a data race if the allocator is used at any point while a thread is being created. The global allocator can be used for flag parsing or registering asan globals.
1 parent 5d9d740 commit 249c313

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ static ThreadRegistry *asan_thread_registry;
4444
static ThreadArgRetval *thread_data;
4545

4646
static Mutex mu_for_thread_context;
47+
static LowLevelAllocator allocator_for_thread_context;
4748

4849
static ThreadContextBase *GetAsanThreadContext(u32 tid) {
4950
Lock lock(&mu_for_thread_context);
50-
return new (GetGlobalLowLevelAllocator()) AsanThreadContext(tid);
51+
return new (allocator_for_thread_context) AsanThreadContext(tid);
5152
}
5253

5354
static void InitThreads() {

0 commit comments

Comments
 (0)