[compiler-rt] r340587 - [sanitizer] Don't call task_for_pid(mach_task_self). NFC.

Kuba Mracek via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 15:55:58 PDT 2018


Author: kuba.brecka
Date: Thu Aug 23 15:55:58 2018
New Revision: 340587

URL: http://llvm.org/viewvc/llvm-project?rev=340587&view=rev
Log:
[sanitizer] Don't call task_for_pid(mach_task_self). NFC.

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

Differential Revision: https://reviews.llvm.org/D51119


Modified:
    compiler-rt/trunk/lib/lsan/lsan_common_mac.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc

Modified: compiler-rt/trunk/lib/lsan/lsan_common_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common_mac.cc?rev=340587&r1=340586&r2=340587&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common_mac.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common_mac.cc Thu Aug 23 15:55:58 2018
@@ -142,12 +142,6 @@ void ProcessGlobalRegions(Frontier *fron
 }
 
 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 @@ void ProcessPlatformSpecificAllocations(
 
   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;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc?rev=340587&r1=340586&r2=340587&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_procmaps_mac.cc Thu Aug 23 15:55:58 2018
@@ -140,12 +140,6 @@ void MemoryMappingLayout::LoadFromCache(
 // 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;
@@ -154,7 +148,7 @@ static mach_header *get_dyld_image_heade
 
   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;
 




More information about the llvm-commits mailing list