Skip to content

Commit 074d17e

Browse files
authored
[scudo] Lock/unlock MutexTSDs in disable/enable. (#169440)
It is possible that a fork could occur while MutexTSDs is being held and then cause a deadlock in a forked process when something attempts to lock it again. Instead add it to the enable/disable list of mutexes.
1 parent 00ffc70 commit 074d17e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler-rt/lib/scudo/standalone/tsd_shared.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,15 @@ struct TSDRegistrySharedT {
9393

9494
void disable() NO_THREAD_SAFETY_ANALYSIS {
9595
Mutex.lock();
96+
MutexTSDs.lock();
9697
for (u32 I = 0; I < TSDsArraySize; I++)
9798
TSDs[I].lock();
9899
}
99100

100101
void enable() NO_THREAD_SAFETY_ANALYSIS {
101102
for (s32 I = static_cast<s32>(TSDsArraySize - 1); I >= 0; I--)
102103
TSDs[I].unlock();
104+
MutexTSDs.unlock();
103105
Mutex.unlock();
104106
}
105107

0 commit comments

Comments
 (0)