[compiler-rt] 96c1fd4 - [tsan] Change personality CHECK to Printf() + Die() (#142821)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 4 13:23:55 PDT 2025


Author: Thurston Dang
Date: 2025-06-04T13:23:50-07:00
New Revision: 96c1fd40bc4b83ef63a581de6c48b2f24a4b89c8

URL: https://github.com/llvm/llvm-project/commit/96c1fd40bc4b83ef63a581de6c48b2f24a4b89c8
DIFF: https://github.com/llvm/llvm-project/commit/96c1fd40bc4b83ef63a581de6c48b2f24a4b89c8.diff

LOG: [tsan] Change personality CHECK to Printf() + Die() (#142821)

Currently, if TSan needs to disable ASLR but is unable to do so, it
aborts with a cryptic message:
```
    ThreadSanitizer: CHECK failed: tsan_platform_linux.cpp:290 "((personality(old_personality | ADDR_NO_RANDOMIZE))) != ((-1))"
```
and a segfault
(https://github.com/google/sanitizers/issues/837#issuecomment-2939267531).

This patch replaces the CHECK with more user-friendly diagnostics and
suggestions via printf, followed by Die().

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index 373acd3d95d01..2c55645a15479 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -259,7 +259,15 @@ static void ReExecIfNeeded(bool ignore_heap) {
             "WARNING: Program is run with randomized virtual address "
             "space, which wouldn't work with ThreadSanitizer on Android.\n"
             "Re-execing with fixed virtual address space.\n");
-    CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
+
+    if (personality(old_personality | ADDR_NO_RANDOMIZE) == -1) {
+      Printf(
+          "FATAL: ThreadSanitizer: unable to disable ASLR (perhaps "
+          "sandboxing is enabled?).\n");
+      Printf("FATAL: Please rerun without sandboxing and/or ASLR.\n");
+      Die();
+    }
+
     reexec = true;
   }
 #      endif
@@ -287,7 +295,18 @@ static void ReExecIfNeeded(bool ignore_heap) {
               "possibly due to high-entropy ASLR.\n"
               "Re-execing with fixed virtual address space.\n"
               "N.B. reducing ASLR entropy is preferable.\n");
-      CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
+
+      if (personality(old_personality | ADDR_NO_RANDOMIZE) == -1) {
+        Printf(
+            "FATAL: ThreadSanitizer: encountered an incompatible memory "
+            "layout but was unable to disable ASLR (perhaps sandboxing is "
+            "enabled?).\n");
+        Printf(
+            "FATAL: Please rerun with lower ASLR entropy, ASLR disabled, "
+            "and/or sandboxing disabled.\n");
+        Die();
+      }
+
       reexec = true;
     } else {
       Printf(


        


More information about the llvm-commits mailing list