[compiler-rt] r319348 - [asan] Fix macOS FindDynamicShadowStart to consider the last gap in the VM map
Kuba Mracek via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 11:44:52 PST 2017
Author: kuba.brecka
Date: Wed Nov 29 11:44:52 2017
New Revision: 319348
URL: http://llvm.org/viewvc/llvm-project?rev=319348&view=rev
Log:
[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
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=319348&r1=319347&r2=319348&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Wed Nov 29 11:44:52 2017
@@ -890,6 +890,11 @@ uptr FindAvailableMemoryRange(uptr shado
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);
More information about the llvm-commits
mailing list