[PATCH] D32190: Make sure to scan mmap'd memory regions for root pointers on OS X

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 19 10:47:20 PDT 2017


kubamracek added inline comments.


================
Comment at: lib/lsan/lsan_common_mac.cc:149-156
+    // This additional root region scan is required on Darwin in order to
+    // detect root regions contained within mmap'd memory regions
+    if (flags()->use_root_regions) {
+      for (uptr i = 0; i < root_regions->size(); i++) {
+        ScanRootRegion(frontier, (*root_regions)[i], address, end_address,
+                       info.protection);
+      }
----------------
fjricci wrote:
> kubamracek wrote:
> > Why is this needed again?  I thought that we only need to account for the VM_MEMORY_OS_ALLOC_ONCE region.
> > 
> > Are we doing something like that on Linux?  Why do we need to scan all mmap'd regions on Darwin only?
> It appears that the Linux implementation of `MemoryMappingLayout` from sanitizer_procmaps includes mmap'd regions, while the Darwin implementation does not. I'm not sure whether that's because mmap-ing works differently on Darwin, or if it's a result of the differences between how we generate the module listing.
I see.  MemoryMappingLayout on Linux parses `/proc/self/maps`, which includes mmap regions, but Darwin uses dyld APIs to only iterate through modules.

For the moment, I think this is fine, but we should make a comment about the difference here.  Ultimately, it would be better to converge the implementations of MemoryMappingLayout to do the same.


https://reviews.llvm.org/D32190





More information about the llvm-commits mailing list