From 4787e5c34ec8f710f545e33285b7a121eaf05e54 Mon Sep 17 00:00:00 2001 From: Dominic Chen Date: Wed, 16 Mar 2022 13:51:08 -0700 Subject: [PATCH] [scudo] Don't unmap other low memory pages if mapping doesn't exist Tests can register multiple allocators, but only the first will initialize since it initializes the TSDRegistrySharedT. Then, destruction of subsequent allocator may end up unmapping a nullptr PrimaryBase with non-zero PrimarySize. Differential Revision: https://reviews.llvm.org/D121858 --- compiler-rt/lib/scudo/standalone/primary64.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h index 6c17855..14784ee 100644 --- a/compiler-rt/lib/scudo/standalone/primary64.h +++ b/compiler-rt/lib/scudo/standalone/primary64.h @@ -89,7 +89,9 @@ public: RegionInfo *Region = getRegionInfo(I); *Region = {}; } - unmap(reinterpret_cast(PrimaryBase), PrimarySize, UNMAP_ALL, &Data); + if (PrimaryBase) + unmap(reinterpret_cast(PrimaryBase), PrimarySize, UNMAP_ALL, + &Data); PrimaryBase = 0U; } -- 2.7.4