tsan: ignore interceptors in few more places

This is preparation to switching to the sanitizer_common Mutex.
Without this change after the switch we will start failing
on existing from the runtime with runtime mutexes held.
Previously it worked because CheckNoLocks did not see sanitizer_common mutexes.

Depends on D106547.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D106558
This commit is contained in:
Dmitry Vyukov 2021-07-22 16:32:55 +02:00
parent cfed8d0faf
commit 3c92eb44d4
2 changed files with 8 additions and 0 deletions

View File

@ -434,6 +434,9 @@ static int setup_at_exit_wrapper(ThreadState *thr, uptr pc, void(*f)(),
// Ensure thread-safety.
BlockingMutexLock l(&interceptor_ctx()->atexit_mu);
// __cxa_atexit calls calloc. If we don't ignore interceptors, we will fail
// due to atexit_mu held on exit from the calloc interceptor.
ScopedIgnoreInterceptors ignore;
res = REAL(__cxa_atexit)((void (*)(void *a))at_exit_wrapper, 0, 0);
// Push AtExitCtx on the top of the stack of callback functions

View File

@ -48,6 +48,9 @@ TEST(MetaMap, FreeRange) {
}
TEST(MetaMap, Sync) {
// EXPECT can call memset/etc. Disable interceptors to prevent
// them from detecting that we exit runtime with mutexes held.
ScopedIgnoreInterceptors ignore;
ThreadState *thr = cur_thread();
MetaMap *m = &ctx->metamap;
u64 block[4] = {}; // fake malloc block
@ -71,6 +74,7 @@ TEST(MetaMap, Sync) {
}
TEST(MetaMap, MoveMemory) {
ScopedIgnoreInterceptors ignore;
ThreadState *thr = cur_thread();
MetaMap *m = &ctx->metamap;
u64 block1[4] = {}; // fake malloc block
@ -108,6 +112,7 @@ TEST(MetaMap, MoveMemory) {
}
TEST(MetaMap, ResetSync) {
ScopedIgnoreInterceptors ignore;
ThreadState *thr = cur_thread();
MetaMap *m = &ctx->metamap;
u64 block[1] = {}; // fake malloc block