Skip to content

Commit

Permalink
[memprof] Switch allocator to dynamic base address (llvm#98510)
Browse files Browse the repository at this point in the history
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@gmail.com>
  • Loading branch information
2 people authored and aaryanshukla committed Jul 14, 2024
1 parent 26d2b12 commit dcde9b0
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions compiler-rt/lib/memprof/memprof_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit dcde9b0

Please sign in to comment.