[sanitizer] Lock/Unlock stack store on fork

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D115210
This commit is contained in:
Vitaly Buka 2021-12-06 17:58:52 -08:00
parent bb8632c1ef
commit 81f9dc8eee
3 changed files with 15 additions and 0 deletions

View File

@ -108,6 +108,14 @@ uptr StackStore::Pack(Compression type) {
return res; return res;
} }
void StackStore::LockAll() {
for (BlockInfo &b : blocks_) b.Lock();
}
void StackStore::UnlockAll() {
for (BlockInfo &b : blocks_) b.Unlock();
}
void StackStore::TestOnlyUnmap() { void StackStore::TestOnlyUnmap() {
for (BlockInfo &b : blocks_) b.TestOnlyUnmap(this); for (BlockInfo &b : blocks_) b.TestOnlyUnmap(this);
internal_memset(this, 0, sizeof(*this)); internal_memset(this, 0, sizeof(*this));

View File

@ -46,6 +46,9 @@ class StackStore {
// Returns the number of released bytes. // Returns the number of released bytes.
uptr Pack(Compression type); uptr Pack(Compression type);
void LockAll();
void UnlockAll();
void TestOnlyUnmap(); void TestOnlyUnmap();
private: private:
@ -106,6 +109,8 @@ class StackStore {
void TestOnlyUnmap(StackStore *store); void TestOnlyUnmap(StackStore *store);
bool Stored(uptr n); bool Stored(uptr n);
bool IsPacked() const; bool IsPacked() const;
void Lock() NO_THREAD_SAFETY_ANALYSIS { mtx_.Lock(); }
void Unlock() NO_THREAD_SAFETY_ANALYSIS { mtx_.Unlock(); }
}; };
BlockInfo blocks_[kBlockCount] = {}; BlockInfo blocks_[kBlockCount] = {};

View File

@ -113,9 +113,11 @@ StackTrace StackDepotGet(u32 id) {
void StackDepotLockAll() { void StackDepotLockAll() {
theDepot.LockAll(); theDepot.LockAll();
stackStore.LockAll();
} }
void StackDepotUnlockAll() { void StackDepotUnlockAll() {
stackStore.UnlockAll();
theDepot.UnlockAll(); theDepot.UnlockAll();
} }