[compiler-rt] [TSan] fix the module map of main executable on darwin platforms (PR #107227)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 05:52:27 PDT 2024


https://github.com/pudge62 updated https://github.com/llvm/llvm-project/pull/107227

>From 39fddfffebe47dc18a64513d4753daae287f2971 Mon Sep 17 00:00:00 2001
From: pudge62 <70063806+pudge62 at users.noreply.github.com>
Date: Wed, 4 Sep 2024 20:05:57 +0800
Subject: [PATCH] fix the module map of main executable on darwin platforms

skip the __PAGEZERO segment when calculate image range
---
 compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
index b44e016a0e5bc6..5ff8d1832556fd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
@@ -433,7 +433,9 @@ void MemoryMappingLayout::DumpListOfModules(
   MemoryMappedSegmentData data;
   segment.data_ = &data;
   while (Next(&segment)) {
-    if (segment.filename[0] == '\0') continue;
+    // skip the __PAGEZERO segment, its vmsize is 0
+    if (segment.filename[0] == '\0' || (segment.start == segment.end))
+      continue;
     LoadedModule *cur_module = nullptr;
     if (!modules->empty() &&
         0 == internal_strcmp(segment.filename, modules->back().full_name())) {



More information about the llvm-commits mailing list