Index: lib/lsan/lsan_common_mac.cc =================================================================== --- lib/lsan/lsan_common_mac.cc +++ lib/lsan/lsan_common_mac.cc @@ -91,7 +91,37 @@ // Scans global variables for heap pointers. void ProcessGlobalRegions(Frontier *frontier) { - CHECK(0 && "unimplemented"); + MemoryMappingLayout memory_mapping(false); + InternalMmapVector modules(/*initial_capacity*/ 128); + memory_mapping.DumpListOfModules(&modules); + for (uptr i = 0; i < modules.size(); ++i) { + // Even when global scanning is disabled, we still need to scan + // system libraries for stashed pointers + if (!flags()->use_globals && modules[i].instrumented()) + continue; + + for (const __sanitizer::LoadedModule::AddressRange &range + : modules[i].ranges()) { + if (range.executable) + continue; + + uptr allocator_begin = 0, allocator_end = 0; + GetAllocatorGlobalRange(&allocator_begin, &allocator_end); + if (range.beg <= allocator_begin && allocator_begin < range.end) { + CHECK_LE(allocator_begin, allocator_end); + CHECK_LE(allocator_end, range.end); + if (range.beg < allocator_begin) + ScanRangeForPointers(range.beg, allocator_begin, frontier, "GLOBAL", + kReachable); + if (allocator_end < range.end) + ScanRangeForPointers(allocator_end, range.end, frontier, "GLOBAL", + kReachable); + } else { + ScanRangeForPointers(range.beg, range.end, frontier, "GLOBAL", + kReachable); + } + } + } } void ProcessPlatformSpecificAllocations(Frontier *frontier) {