[PATCH] D27083: [sanitizer] Handle malloc_destroy_zone() on Darwin

Anna Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 15:54:06 PST 2016


zaks.anna added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_malloc_mac.inc:68
+
+// If libmalloc tries to set up a different zone as malloc_zones[0], it will
+// call mprotect(malloc_zones, ..., PROT_READ).  This interceptor will catch
----------------
I'd add a comment that explains the intent here (why are we doing this), ex: 
// Ensure that the sanitizer_zone is registered as malloc_zones[0].


================
Comment at: lib/sanitizer_common/sanitizer_malloc_mac.inc:74
+    if (malloc_num_zones > 0 && malloc_zones[0] != &sanitizer_zone) {
+      for (unsigned i = 0; i < malloc_num_zones; i++) {
+        if (malloc_zones[i] == &sanitizer_zone) {
----------------
You could strengthen the condition above to `malloc_num_zones > 1 &&` and start iteration from '1'. If there is a single zone:
 - if it is sanitizer_zone, we are good to go.
 - if it is not a sanitizer_zone, there is nothing to swap it with.


https://reviews.llvm.org/D27083





More information about the llvm-commits mailing list