[llvm-commits] [compiler-rt] r164021 - /compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
Alexey Samsonov
samsonov at google.com
Mon Sep 17 02:14:11 PDT 2012
Author: samsonov
Date: Mon Sep 17 04:14:11 2012
New Revision: 164021
URL: http://llvm.org/viewvc/llvm-project?rev=164021&view=rev
Log:
[TSan] If we detect an unlimited stack, try to re-exec with limited stack
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=164021&r1=164020&r2=164021&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Mon Sep 17 04:14:11 2012
@@ -202,6 +202,17 @@
lim.rlim_max = 0;
setrlimit(RLIMIT_CORE, (rlimit*)&lim);
}
+ // TSan doesn't play well with unlimited stack size (as stack
+ // overlaps with shadow memory). If we detect unlimited stack size,
+ // we re-exec the program with limited stack size as a best effort.
+ if (StackSizeIsUnlimited()) {
+ const uptr kMaxStackSize = 32 * 1024 * 1024; // 32 Mb
+ Report("WARNING: Program is run with unlimited stack size, which "
+ "wouldn't work with ThreadSanitizer.\n");
+ Report("Re-execing with stack size limited to %zd bytes.\n", kMaxStackSize);
+ SetStackSizeLimitInBytes(kMaxStackSize);
+ ReExec();
+ }
#ifndef TSAN_GO
CheckPIE();
More information about the llvm-commits
mailing list