[PATCH] D14334: [asan] Remove system_malloc_zone

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 4 08:17:49 PST 2015


kubabrecka created this revision.
kubabrecka added reviewers: samsonov, glider, kcc, dvyukov.
kubabrecka added subscribers: llvm-commits, zaks.anna, ismailp, jasonk.

This seems to be dead code – `system_malloc_zone` is initialized as null and we never assign to it.  This code is apparently currently never executed (in ASan), but is causes trouble for the TSan OS X port.  Let's replace the checks with `COMMON_MALLOC_ENTER` (`ENSURE_ASAN_INITED()`).

http://reviews.llvm.org/D14334

Files:
  lib/sanitizer_common/sanitizer_malloc_mac.inc

Index: lib/sanitizer_common/sanitizer_malloc_mac.inc
===================================================================
--- lib/sanitizer_common/sanitizer_malloc_mac.inc
+++ lib/sanitizer_common/sanitizer_malloc_mac.inc
@@ -29,8 +29,6 @@
 // Similar code is used in Google Perftools,
 // http://code.google.com/p/google-perftools.
 
-// TODO(glider): do we need both zones?
-static malloc_zone_t *system_malloc_zone = 0;
 static malloc_zone_t sanitizer_zone;
 
 INTERCEPTOR(malloc_zone_t *, malloc_create_zone,
@@ -155,10 +153,7 @@
 extern "C"
 SANITIZER_INTERFACE_ATTRIBUTE
 void *__sanitizer_mz_malloc(malloc_zone_t *zone, uptr size) {
-  if (UNLIKELY(!COMMON_MALLOC_SANITIZER_INITIALIZED)) {
-    CHECK(system_malloc_zone);
-    return malloc_zone_malloc(system_malloc_zone, size);
-  }
+  COMMON_MALLOC_ENTER();
   COMMON_MALLOC_MALLOC(size);
   return p;
 }
@@ -184,10 +179,7 @@
 extern "C"
 SANITIZER_INTERFACE_ATTRIBUTE
 void *__sanitizer_mz_valloc(malloc_zone_t *zone, size_t size) {
-  if (UNLIKELY(!COMMON_MALLOC_SANITIZER_INITIALIZED)) {
-    CHECK(system_malloc_zone);
-    return malloc_zone_valloc(system_malloc_zone, size);
-  }
+  COMMON_MALLOC_ENTER();
   COMMON_MALLOC_VALLOC(size);
   return p;
 }
@@ -246,10 +238,7 @@
 extern "C"
 SANITIZER_INTERFACE_ATTRIBUTE
 void *__sanitizer_mz_memalign(malloc_zone_t *zone, size_t align, size_t size) {
-  if (UNLIKELY(!COMMON_MALLOC_SANITIZER_INITIALIZED)) {
-    CHECK(system_malloc_zone);
-    return malloc_zone_memalign(system_malloc_zone, align, size);
-  }
+  COMMON_MALLOC_ENTER();
   COMMON_MALLOC_MEMALIGN(align, size);
   return p;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14334.39207.patch
Type: text/x-patch
Size: 1606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/9b76c296/attachment.bin>


More information about the llvm-commits mailing list