[compiler-rt] b12e141 - [memprof] Switch allocator to dynamic base address (#98510)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 19:23:59 PDT 2024


Author: Thurston Dang
Date: 2024-07-11T19:23:56-07:00
New Revision: b12e141fb14a8b603984e1d29339e344e0db36ce

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

LOG: [memprof] Switch allocator to dynamic base address (#98510)

memprof_rtl.cpp calls InitializeShadowMemory() - which
dynamically/"randomly" chooses a base address for the shadow mapping -
prior to InitializeAllocator(). If we are unlucky, the shadow memory may
be mapped in the same region where the allocator wants to be.

This patch fixes the issue by changing the allocator to dynamically
choosing a base address, as suggested by Vitaly. For comparison, HWASan
already dynamically chooses the base addresses for the shadow mapping
and allocator.

The "unlucky" failure was observed on a new buildbot:
https://lab.llvm.org/buildbot/#/builders/66/builds/1361/steps/17/logs/stdio

---------

Co-authored-by: Vitaly Buka <vitalybuka at gmail.com>

Added: 
    

Modified: 
    compiler-rt/lib/memprof/memprof_allocator.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/memprof/memprof_allocator.h b/compiler-rt/lib/memprof/memprof_allocator.h
index 89e924f80d41a..6d898f06f7e42 100644
--- a/compiler-rt/lib/memprof/memprof_allocator.h
+++ b/compiler-rt/lib/memprof/memprof_allocator.h
@@ -46,11 +46,7 @@ struct MemprofMapUnmapCallback {
   void OnUnmap(uptr p, uptr size) const;
 };
 
-#if SANITIZER_APPLE
-constexpr uptr kAllocatorSpace = 0x600000000000ULL;
-#else
-constexpr uptr kAllocatorSpace = 0x500000000000ULL;
-#endif
+constexpr uptr kAllocatorSpace = ~(uptr)0;
 constexpr uptr kAllocatorSize = 0x40000000000ULL; // 4T.
 typedef DefaultSizeClassMap SizeClassMap;
 template <typename AddressSpaceViewTy>


        


More information about the llvm-commits mailing list