diff --git a/compiler-rt/lib/scudo/standalone/tests/tsd_test.cpp b/compiler-rt/lib/scudo/standalone/tests/tsd_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/tsd_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/tsd_test.cpp @@ -201,6 +201,7 @@ TEST(ScudoTSDTest, TSDRegistryTSDsCount) { Ready = false; + Pointers.clear(); using AllocatorT = MockAllocator; auto Deleter = [](AllocatorT *A) { A->unmapTestOnly(); diff --git a/compiler-rt/lib/scudo/standalone/tsd_exclusive.h b/compiler-rt/lib/scudo/standalone/tsd_exclusive.h --- a/compiler-rt/lib/scudo/standalone/tsd_exclusive.h +++ b/compiler-rt/lib/scudo/standalone/tsd_exclusive.h @@ -43,7 +43,14 @@ initLinkerInitialized(Instance); // Sets Initialized. } - void unmapTestOnly() {} + void unmapTestOnly() { + Allocator *Instance = + reinterpret_cast(pthread_getspecific(PThreadKey)); + if (!Instance) + return; + ThreadTSD.commitBack(Instance); + State = {}; + } ALWAYS_INLINE void initThreadMaybe(Allocator *Instance, bool MinimalInit) { if (LIKELY(State.InitState != ThreadState::NotInitialized))