Skip to content

Commit 388b83e

Browse files
committed
[tsan] Change personality CHECK to Printf() + Die()
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 fd452da commit 388b83e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ 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("FATAL: ThreadSanitizer: unable to disable ASLR (perhaps "
265+
"sandboxing is enabled?).\n");
266+
Printf("FATAL: Please rerun without sandboxing or ASLR.\n");
267+
Die();
268+
}
269+
263270
reexec = true;
264271
}
265272
# endif
@@ -287,7 +294,16 @@ static void ReExecIfNeeded(bool ignore_heap) {
287294
"possibly due to high-entropy ASLR.\n"
288295
"Re-execing with fixed virtual address space.\n"
289296
"N.B. reducing ASLR entropy is preferable.\n");
290-
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
297+
298+
if (personality(old_personality | ADDR_NO_RANDOMIZE) == -1) {
299+
Printf("FATAL: ThreadSanitizer: encountered an incompatible memory "
300+
"but was unable to disable ASLR (perhaps sandboxing is "
301+
"enabled?).\n");
302+
Printf("FATAL: Please rerun with lower ASLR entropy, ASLR disabled, "
303+
"and/or sandboxing disabled.\n");
304+
Die();
305+
}
306+
291307
reexec = true;
292308
} else {
293309
Printf(

0 commit comments

Comments
 (0)