diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp @@ -1182,7 +1182,7 @@ return err ? 0 : vm_info.max_address; } -uptr GetMaxUserVirtualAddress() { +static uptr GetMaxUserVirtualAddressImpl() { static uptr max_vm = GetTaskInfoMaxAddress(); if (max_vm != 0) return max_vm - 1; @@ -1197,7 +1197,7 @@ #else // !SANITIZER_IOS -uptr GetMaxUserVirtualAddress() { +static uptr GetMaxUserVirtualAddressImpl() { # if SANITIZER_WORDSIZE == 64 return (1ULL << 47) - 1; // 0x00007fffffffffffUL; # else // SANITIZER_WORDSIZE == 32 @@ -1207,6 +1207,12 @@ } #endif +uptr GetMaxUserVirtualAddress() { + static uptr max_vm = GetMaxUserVirtualAddressImpl(); + CHECK_LE(max_vm, SANITIZER_MMAP_RANGE_SIZE); + return max_vm; +} + uptr GetMaxVirtualAddress() { return GetMaxUserVirtualAddress(); }