Skip to content

[tsan] Lock/Unlock allocator and stacks on fork #96600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_mman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_errno.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "tsan_flags.h"
#include "tsan_interface.h"
#include "tsan_report.h"
Expand Down Expand Up @@ -119,9 +120,18 @@ ScopedGlobalProcessor::~ScopedGlobalProcessor() {
void AllocatorLockBeforeFork() SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
global_proc()->internal_alloc_mtx.Lock();
InternalAllocatorLock();
#if !SANITIZER_APPLE
// OS X allocates from hooks, see 6a3958247a.
allocator()->ForceLock();
StackDepotLockBeforeFork();
#endif
}

void AllocatorUnlockAfterFork(bool child) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
#if !SANITIZER_APPLE
StackDepotUnlockAfterFork(child);
allocator()->ForceUnlock();
#endif
InternalAllocatorUnlock();
global_proc()->internal_alloc_mtx.Unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// FIXME: It probably hangs on this platform.
// UNSUPPORTED: ppc

// FIXME: TSAN does not lock allocator.
// UNSUPPORTED: tsan

// FIXME: False stack overflow report
// UNSUPPORTED: android && asan

Expand Down
Loading