[compiler-rt] [TSan] [Darwin] Fix off by one in TSAN init due to MemoryRangeIsAvailable call (PR #169008)
Andrew Haberlandt via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 23:01:30 PST 2025
https://github.com/ndrewh created https://github.com/llvm/llvm-project/pull/169008
This fixes a bug in https://github.com/llvm/llvm-project/pull/167797 where an upper-bound was mistaken to be exclusive when it was actually inclusive. MemoryRangeIsAvailable takes an inclusive upper bound, and if beginning == end it will check for overlap with a range of size 1.
Here, we want to check if `HiAppMemEnd() - 1` is mapped. If it is, the memory layout should be marked unsupported.
rdar://164815619
>From bcb5f82a47ac7ba5429bf2648f9ee2c3a0122819 Mon Sep 17 00:00:00 2001
From: Andrew Haberlandt <ahaberlandt at apple.com>
Date: Thu, 20 Nov 2025 22:58:20 -0800
Subject: [PATCH] Fix off by one in TSAN init due to MemoryRangeIsAvailable
call
---
compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
index f6fe2405254e7..da735fba663aa 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cpp
@@ -235,7 +235,7 @@ void InitializePlatformEarly() {
}
// In some configurations, the max_vm is expanded, but much of this space is
// already mapped. TSAN will not work in this configuration.
- if (!MemoryRangeIsAvailable(HiAppMemEnd() - 1, HiAppMemEnd())) {
+ if (!MemoryRangeIsAvailable(HiAppMemEnd() - 1, HiAppMemEnd() - 1)) {
Report(
"ThreadSanitizer: Unsupported virtual memory layout: Address %p is "
"already mapped.\n",
More information about the llvm-commits
mailing list