[PATCH] D51119: [sanitizer] Don't call task_for_pid(mach_task_self). NFC.

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 12:09:46 PDT 2018


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

Calling `task_for_pid` with `mach_task_self` is just returning `mach_task_self` anyway, but it also triggers system warnings (task_for_pid is only supposed to be used by high-privileged executables). NFC.

rdar://problem/39198248


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D51119

Files:
  lib/lsan/lsan_common_mac.cc
  lib/sanitizer_common/sanitizer_procmaps_mac.cc


Index: lib/sanitizer_common/sanitizer_procmaps_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_procmaps_mac.cc
+++ lib/sanitizer_common/sanitizer_procmaps_mac.cc
@@ -140,21 +140,15 @@
 // early in the process, when dyld is one of the only images loaded,
 // so it will be hit after only a few iterations.
 static mach_header *get_dyld_image_header() {
-  mach_port_name_t port;
-  if (task_for_pid(mach_task_self(), internal_getpid(), &port) !=
-      KERN_SUCCESS) {
-    return nullptr;
-  }
-
   unsigned depth = 1;
   vm_size_t size = 0;
   vm_address_t address = 0;
   kern_return_t err = KERN_SUCCESS;
   mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64;
 
   while (true) {
     struct vm_region_submap_info_64 info;
-    err = vm_region_recurse_64(port, &address, &size, &depth,
+    err = vm_region_recurse_64(mach_task_self(), &address, &size, &depth,
                                (vm_region_info_t)&info, &count);
     if (err != KERN_SUCCESS) return nullptr;
 
Index: lib/lsan/lsan_common_mac.cc
===================================================================
--- lib/lsan/lsan_common_mac.cc
+++ lib/lsan/lsan_common_mac.cc
@@ -142,12 +142,6 @@
 }
 
 void ProcessPlatformSpecificAllocations(Frontier *frontier) {
-  mach_port_name_t port;
-  if (task_for_pid(mach_task_self(), internal_getpid(), &port)
-      != KERN_SUCCESS) {
-    return;
-  }
-
   unsigned depth = 1;
   vm_size_t size = 0;
   vm_address_t address = 0;
@@ -158,7 +152,7 @@
 
   while (err == KERN_SUCCESS) {
     struct vm_region_submap_info_64 info;
-    err = vm_region_recurse_64(port, &address, &size, &depth,
+    err = vm_region_recurse_64(mach_task_self(), &address, &size, &depth,
                                (vm_region_info_t)&info, &count);
 
     uptr end_address = address + size;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51119.162021.patch
Type: text/x-patch
Size: 1862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/b390b0b6/attachment.bin>


More information about the llvm-commits mailing list