summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2012-11-28 12:19:50 +0000
committerDmitry Vyukov <dvyukov@google.com>2012-11-28 12:19:50 +0000
commite1a7f338a34f358b8866a7d08a21a1756e43f2da (patch)
treef22d56ebf846e7aae5f1aee51938b29140fbad5b /compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
parent3eb16c543e2cc3f0415012df03dc6189359d6f81 (diff)
downloadbcm5719-llvm-e1a7f338a34f358b8866a7d08a21a1756e43f2da.tar.gz
bcm5719-llvm-e1a7f338a34f358b8866a7d08a21a1756e43f2da.zip
tsan: dynamic history size
introduces history_size parameter that can be used to control trace size at startup llvm-svn: 168786
Diffstat (limited to 'compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc38
1 files changed, 30 insertions, 8 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
index ee90a24000a..0a2ec3cdd10 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
@@ -202,28 +202,50 @@ static int InitTlsSize() {
}
#endif // #ifndef TSAN_GO
+static rlim_t getlim(int res) {
+ rlimit rlim;
+ CHECK_EQ(0, getrlimit(res, &rlim));
+ return rlim.rlim_cur;
+}
+
+static void setlim(int res, rlim_t lim) {
+ // The following magic is to prevent clang from replacing it with memset.
+ volatile rlimit rlim;
+ rlim.rlim_cur = lim;
+ rlim.rlim_max = lim;
+ setrlimit(res, (rlimit*)&rlim);
+}
+
const char *InitializePlatform() {
void *p = 0;
if (sizeof(p) == 8) {
// Disable core dumps, dumping of 16TB usually takes a bit long.
- // The following magic is to prevent clang from replacing it with memset.
- volatile rlimit lim;
- lim.rlim_cur = 0;
- lim.rlim_max = 0;
- setrlimit(RLIMIT_CORE, (rlimit*)&lim);
+ setlim(RLIMIT_CORE, 0);
}
+ bool reexec = false;
// 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
+ if (getlim(RLIMIT_STACK) == (rlim_t)-1) {
+ const uptr kMaxStackSize = 32 * 1024 * 1024;
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();
+ reexec = true;
}
+ if (getlim(RLIMIT_AS) != (rlim_t)-1) {
+ Report("WARNING: Program is run with limited virtual address space, which "
+ "wouldn't work with ThreadSanitizer.\n");
+ Report("Re-execing with unlimited virtual address space.\n");
+ setlim(RLIMIT_AS, -1);
+ reexec = true;
+ }
+
+ if (reexec)
+ ReExec();
+
#ifndef TSAN_GO
CheckPIE();
g_tls_size = (uptr)InitTlsSize();
OpenPOWER on IntegriCloud