Skip to content

Commit 96c1fd4

Browse files
authored
[tsan] Change personality CHECK to Printf() + Die() (llvm#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 (google/sanitizers#837 (comment)). This patch replaces the CHECK with more user-friendly diagnostics and suggestions via printf, followed by Die().
1 parent 6dd3891 commit 96c1fd4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,15 @@ static void ReExecIfNeeded(bool ignore_heap) {
259259
"WARNING: Program is run with randomized virtual address "
260260
"space, which wouldn't work with ThreadSanitizer on Android.\n"
261261
"Re-execing with fixed virtual address space.\n");
262-
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
262+
263+
if (personality(old_personality | ADDR_NO_RANDOMIZE) == -1) {
264+
Printf(
265+
"FATAL: ThreadSanitizer: unable to disable ASLR (perhaps "
266+
"sandboxing is enabled?).\n");
267+
Printf("FATAL: Please rerun without sandboxing and/or ASLR.\n");
268+
Die();
269+
}
270+
263271
reexec = true;
264272
}
265273
# endif
@@ -287,7 +295,18 @@ static void ReExecIfNeeded(bool ignore_heap) {
287295
"possibly due to high-entropy ASLR.\n"
288296
"Re-execing with fixed virtual address space.\n"
289297
"N.B. reducing ASLR entropy is preferable.\n");
290-
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
298+
299+
if (personality(old_personality | ADDR_NO_RANDOMIZE) == -1) {
300+
Printf(
301+
"FATAL: ThreadSanitizer: encountered an incompatible memory "
302+
"layout but was unable to disable ASLR (perhaps sandboxing is "
303+
"enabled?).\n");
304+
Printf(
305+
"FATAL: Please rerun with lower ASLR entropy, ASLR disabled, "
306+
"and/or sandboxing disabled.\n");
307+
Die();
308+
}
309+
291310
reexec = true;
292311
} else {
293312
Printf(

0 commit comments

Comments
 (0)