diff options
author | Kuba Mracek <mracek@apple.com> | 2017-11-29 19:44:52 +0000 |
---|---|---|
committer | Kuba Mracek <mracek@apple.com> | 2017-11-29 19:44:52 +0000 |
commit | 2cebb22e8bb65be4ce66eb8ecd8c8dc1496ff062 (patch) | |
tree | 557a1ef9b1151ad011ba3a762330170270c04835 | |
parent | f1459c278658344f581330056f974ad1376dee78 (diff) |
[asan] Fix macOS FindDynamicShadowStart to consider the last gap in the VM map
It looks FindDynamicShadowStart has a bug: When iterating over the memory map, we will not consider the very last gap in the address space. Let's fix that.
Differential Revision: https://reviews.llvm.org/D39989
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319348 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/sanitizer_mac.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_mac.cc b/lib/sanitizer_common/sanitizer_mac.cc index a43260f84..86e76287d 100644 --- a/lib/sanitizer_common/sanitizer_mac.cc +++ b/lib/sanitizer_common/sanitizer_mac.cc @@ -890,6 +890,11 @@ uptr FindAvailableMemoryRange(uptr shadow_size, mach_msg_type_number_t count = kRegionInfoSize; kr = mach_vm_region_recurse(mach_task_self(), &address, &vmsize, &depth, (vm_region_info_t)&vminfo, &count); + if (kr == KERN_INVALID_ADDRESS) { + // No more regions beyond "address", consider the gap at the end of VM. + address = GetMaxVirtualAddress() + 1; + vmsize = 0; + } if (free_begin != address) { // We found a free region [free_begin..address-1]. uptr gap_start = RoundUpTo((uptr)free_begin + left_padding, alignment); |