[PATCH] D50275: [sanitizer] When setting up shadow memory on iOS, fix handling the return value of task_info on older OS versions

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 3 15:12:58 PDT 2018


kubamracek created this revision.
kubamracek added reviewers: george.karpenkov, delcypher.
kubamracek added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

task_vm_info is a "revisioned" structure, new OS versions add fields to the end, and compatibility is based on the reported size. On older OS versions, min_address/max_address is not filled back. Let's handle that case. Unfortunately, we can't really write a test (as the failure only happens when on a specific OS version).


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D50275

Files:
  lib/sanitizer_common/sanitizer_mac.cc


Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -893,7 +893,7 @@
   __sanitizer_task_vm_info vm_info = {};
   mach_msg_type_number_t count = __SANITIZER_TASK_VM_INFO_COUNT;
   int err = task_info(mach_task_self(), TASK_VM_INFO, (int *)&vm_info, &count);
-  if (err == 0) {
+  if (err == 0 && vm_info.max_address != 0) {
     return vm_info.max_address - 1;
   } else {
     // xnu cannot provide vm address limit


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50275.159102.patch
Type: text/x-patch
Size: 565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/f3179dc8/attachment.bin>


More information about the llvm-commits mailing list