Skip to content

Commit 81f9dc8

Browse files
committed
[sanitizer] Lock/Unlock stack store on fork
Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D115210
1 parent bb8632c commit 81f9dc8

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ uptr StackStore::Pack(Compression type) {
108108
return res;
109109
}
110110

111+
void StackStore::LockAll() {
112+
for (BlockInfo &b : blocks_) b.Lock();
113+
}
114+
115+
void StackStore::UnlockAll() {
116+
for (BlockInfo &b : blocks_) b.Unlock();
117+
}
118+
111119
void StackStore::TestOnlyUnmap() {
112120
for (BlockInfo &b : blocks_) b.TestOnlyUnmap(this);
113121
internal_memset(this, 0, sizeof(*this));

compiler-rt/lib/sanitizer_common/sanitizer_stack_store.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class StackStore {
4646
// Returns the number of released bytes.
4747
uptr Pack(Compression type);
4848

49+
void LockAll();
50+
void UnlockAll();
51+
4952
void TestOnlyUnmap();
5053

5154
private:
@@ -106,6 +109,8 @@ class StackStore {
106109
void TestOnlyUnmap(StackStore *store);
107110
bool Stored(uptr n);
108111
bool IsPacked() const;
112+
void Lock() NO_THREAD_SAFETY_ANALYSIS { mtx_.Lock(); }
113+
void Unlock() NO_THREAD_SAFETY_ANALYSIS { mtx_.Unlock(); }
109114
};
110115

111116
BlockInfo blocks_[kBlockCount] = {};

compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ StackTrace StackDepotGet(u32 id) {
113113

114114
void StackDepotLockAll() {
115115
theDepot.LockAll();
116+
stackStore.LockAll();
116117
}
117118

118119
void StackDepotUnlockAll() {
120+
stackStore.UnlockAll();
119121
theDepot.UnlockAll();
120122
}
121123

0 commit comments

Comments
 (0)