[compiler-rt] [asan] Switch allocator to dynamic base address (PR #98511)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 10:59:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Thurston Dang (thurstond)
<details>
<summary>Changes</summary>
This ports a proposed memprof fix (https://github.com/llvm/llvm-project/pull/98510), which has a shadow memory and allocator layout that is similar to ASan. Although we have only observed the failure for memprof on a buildbot [*], it could theoretically happen for ASan.
asan_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.
[*] https://lab.llvm.org/buildbot/#/builders/66/builds/1361/steps/17/logs/stdio
---
Full diff: https://github.com/llvm/llvm-project/pull/98511.diff
1 Files Affected:
- (modified) compiler-rt/lib/asan/asan_allocator.h (+1-1)
``````````diff
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h
index c3c4fae85b129..8fb113dd62f98 100644
--- a/compiler-rt/lib/asan/asan_allocator.h
+++ b/compiler-rt/lib/asan/asan_allocator.h
@@ -214,7 +214,7 @@ const uptr kAllocatorSpace = 0x600000000000ULL;
const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
typedef DefaultSizeClassMap SizeClassMap;
# else
-const uptr kAllocatorSpace = 0x500000000000ULL;
+const uptr kAllocatorSpace = ~(uptr)0;
const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
typedef DefaultSizeClassMap SizeClassMap;
# endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/98511
More information about the llvm-commits
mailing list