[compiler-rt] [Sanitizers][Apple] Fix logic bugs that break RestrictMemoryToMaxAddress (PR #124712)

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 12:11:05 PST 2025


================
@@ -1272,10 +1272,11 @@ uptr FindAvailableMemoryRange(uptr size, uptr alignment, uptr left_padding,
     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) {
+    if (kr == KERN_INVALID_ADDRESS || address > max_vm_address) {
----------------
delcypher wrote:

Nit: There should probably a comment here explaining that `mach_vm_region_recurse` doesn't return `KERN_INVALID_ADDRESS` in some cases.

https://github.com/llvm/llvm-project/pull/124712


More information about the llvm-commits mailing list