[compiler-rt] f30fe16 - scudo: Call setCurrentTSD(nullptr) when bringing down the TSD registry in tests.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 09:55:21 PST 2019


Author: Peter Collingbourne
Date: 2019-11-27T09:55:14-08:00
New Revision: f30fe16d4902617a33dac1ebca066a7cb7e0f2ec

URL: https://github.com/llvm/llvm-project/commit/f30fe16d4902617a33dac1ebca066a7cb7e0f2ec
DIFF: https://github.com/llvm/llvm-project/commit/f30fe16d4902617a33dac1ebca066a7cb7e0f2ec.diff

LOG: scudo: Call setCurrentTSD(nullptr) when bringing down the TSD registry in tests.

Otherwise, we will hit a use-after-free when testing multiple instances of
the same allocator on the same thread. This only recently became a problem
with D70552 which caused us to run both ScudoCombinedTest.BasicCombined and
ScudoCombinedTest.ReleaseToOS on the unit tests' main thread.

Differential Revision: https://reviews.llvm.org/D70760

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/tsd_shared.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/tsd_shared.h b/compiler-rt/lib/scudo/standalone/tsd_shared.h
index a43cf3fc3376..5f58068edf78 100644
--- a/compiler-rt/lib/scudo/standalone/tsd_shared.h
+++ b/compiler-rt/lib/scudo/standalone/tsd_shared.h
@@ -50,6 +50,7 @@ template <class Allocator, u32 MaxTSDCount> struct TSDRegistrySharedT {
   void unmapTestOnly() {
     unmap(reinterpret_cast<void *>(TSDs),
           sizeof(TSD<Allocator>) * NumberOfTSDs);
+    setCurrentTSD(nullptr);
   }
 
   ALWAYS_INLINE void initThreadMaybe(Allocator *Instance,


        


More information about the llvm-commits mailing list