aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpudge62 <maruipu2019@gmail.com>2024-09-26 15:22:14 +0800
committerGitHub <noreply@github.com>2024-09-26 00:22:14 -0700
commit781cb10f33beb9a829857de41827c0e4ff83bb32 (patch)
tree416f881e1c80e8f7b94a303ab8d285d51a817a2e
parent571a867f1f7abc4a58420f60b2b121b5fd13e26b (diff)
downloadllvm-781cb10f33beb9a829857de41827c0e4ff83bb32.zip
llvm-781cb10f33beb9a829857de41827c0e4ff83bb32.tar.gz
llvm-781cb10f33beb9a829857de41827c0e4ff83bb32.tar.bz2
[TSan] fix the module map of main executable on darwin platforms (#107227)
In the executable image on Darwin platforms, there is a `__PAGEZERO` segment with a size of 0. When calculating the module map, this segment must be skipped to avoid errors. The previous implementation inaccurately calculated the executable image's range, starting the address at `0 + slide`.
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cpp
index b44e016a..5ff8d18 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())) {