[compiler-rt] [sanitizer] Warn if allocator size exceeds max user virtual address (PR #152428)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 19:20:45 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Thurston Dang (thurstond)
<details>
<summary>Changes</summary>
This warns the user of incompatible configurations, such as 39-bit and 42-bit VMAs for AArch64 non-Android Linux ASan (https://github.com/llvm/llvm-project/issues/145259).
---
Full diff: https://github.com/llvm/llvm-project/pull/152428.diff
1 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h (+12)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 51ac1b6ae4975..56d40c19b0f0c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -113,6 +113,18 @@ class SizeClassAllocator64 {
// ~(uptr)0.
void Init(s32 release_to_os_interval_ms, uptr heap_start = 0) {
uptr TotalSpaceSize = kSpaceSize + AdditionalSize();
+
+ uptr MaxAddr = GetMaxUserVirtualAddress();
+ // VReport does not call the sanitizer allocator.
+ VReport(3, "Max user virtual address: 0x%zx\n", MaxAddr);
+ VReport(3, "Total space size for primary allocator: 0x%zx\n",
+ TotalSpaceSize);
+ if (TotalSpaceSize >= MaxAddr)
+ VReport(0, "Error: heap size %zx exceeds max user virtual address %zx\n",
+ TotalSpaceSize, MaxAddr);
+ // We can't easily adjust the requested heap size, because kSpaceSize is
+ // const (for optimization) and used throughout the code.
+
PremappedHeap = heap_start != 0;
if (PremappedHeap) {
CHECK(!kUsingConstantSpaceBeg);
``````````
</details>
https://github.com/llvm/llvm-project/pull/152428
More information about the llvm-commits
mailing list