[compiler-rt] [sanitizer_common][tsan] Improve message for unsupported vm config on Apple platforms (PR #158665)

Dan Blackwell via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 04:33:53 PDT 2025


================
@@ -226,9 +226,19 @@ static void ThreadTerminateCallback(uptr thread) {
 void InitializePlatformEarly() {
 #  if !SANITIZER_GO && SANITIZER_IOS
   uptr max_vm = GetMaxUserVirtualAddress() + 1;
-  if (max_vm != HiAppMemEnd()) {
-    Printf("ThreadSanitizer: unsupported vm address limit %p, expected %p.\n",
-           (void *)max_vm, (void *)HiAppMemEnd());
+  if (max_vm < HiAppMemEnd()) {
+    Printf(
+        "ThreadSanitizer: Unsupported virtual memory layout:\n\tVM address "
+        "limit = %p\n\tExpected %p.\n",
+        (void*)max_vm, (void*)HiAppMemEnd());
+    Die();
+  }
+  // In some configurations, the max_vm is expanded, but much of this space is
+  // already mapped. TSAN will not work in this configuration.
+  else if (IsAddressInMappedRegion(HiAppMemEnd() - 1)) {
----------------
DanBlackwell wrote:

NIT: Given the above if-statement is no-return, this could just be `if` (no `else`), in line with https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code

https://github.com/llvm/llvm-project/pull/158665


More information about the llvm-commits mailing list