[compiler-rt] r215763 - [TSan] Initialize flags as early as possible. Disables back coredump, accidentally enabled in r215479. Add a test.
Alexey Samsonov
vonosmas at gmail.com
Fri Aug 15 12:53:51 PDT 2014
Author: samsonov
Date: Fri Aug 15 14:53:51 2014
New Revision: 215763
URL: http://llvm.org/viewvc/llvm-project?rev=215763&view=rev
Log:
[TSan] Initialize flags as early as possible. Disables back coredump, accidentally enabled in r215479. Add a test.
Added:
compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_mac.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_windows.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=215763&r1=215762&r2=215763&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Fri Aug 15 14:53:51 2014
@@ -128,7 +128,7 @@ void FlushShadowMemory();
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive);
uptr GetRSS();
-const char *InitializePlatform();
+void InitializePlatform();
void FinalizePlatform();
// The additional page is to catch shadow stack overflow as paging fault.
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=215763&r1=215762&r2=215763&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Fri Aug 15 14:53:51 2014
@@ -332,7 +332,7 @@ static void InitDataSeg() {
#endif // #ifndef TSAN_GO
-const char *InitializePlatform() {
+void InitializePlatform() {
DisableCoreDumperIfNecessary();
// Go maps shadow memory lazily and works fine with limited address space.
@@ -369,7 +369,6 @@ const char *InitializePlatform() {
InitTlsSize();
InitDataSeg();
#endif
- return GetEnv(kTsanOptionsEnv);
}
bool IsGlobalVar(uptr addr) {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_mac.cc?rev=215763&r1=215762&r2=215763&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_mac.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_mac.cc Fri Aug 15 14:53:51 2014
@@ -73,9 +73,8 @@ void InitializeShadowMemory() {
}
#endif
-const char *InitializePlatform() {
+void InitializePlatform() {
DisableCoreDumperIfNecessary();
- return GetEnv(kTsanOptionsEnv);
}
void FinalizePlatform() {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_windows.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_windows.cc?rev=215763&r1=215762&r2=215763&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_windows.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_windows.cc Fri Aug 15 14:53:51 2014
@@ -35,8 +35,7 @@ uptr GetRSS() {
return 0;
}
-const char *InitializePlatform() {
- return GetEnv(kTsanOptionsEnv);
+void InitializePlatform() {
}
void FinalizePlatform() {
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=215763&r1=215762&r2=215763&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Fri Aug 15 14:53:51 2014
@@ -289,18 +289,19 @@ void Initialize(ThreadState *thr) {
// Install tool-specific callbacks in sanitizer_common.
SetCheckFailedCallback(TsanCheckFailed);
+ ctx = new(ctx_placeholder) Context;
+ const char *options = GetEnv(kTsanOptionsEnv);
+ InitializeFlags(&ctx->flags, options);
#ifndef TSAN_GO
InitializeAllocator();
#endif
InitializeInterceptors();
- const char *env = InitializePlatform();
+ InitializePlatform();
InitializeMutex();
InitializeDynamicAnnotations();
- ctx = new(ctx_placeholder) Context;
#ifndef TSAN_GO
InitializeShadowMemory();
#endif
- InitializeFlags(&ctx->flags, env);
// Setup correct file descriptor for error reports.
__sanitizer_set_report_path(flags()->log_path);
InitializeSuppressions();
@@ -336,7 +337,6 @@ void Initialize(ThreadState *thr) {
}
int Finalize(ThreadState *thr) {
- Context *ctx = __tsan::ctx;
bool failed = false;
if (flags()->atexit_sleep_ms > 0 && ThreadCount(thr) > 1)
Added: compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc?rev=215763&view=auto
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc (added)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc Fri Aug 15 14:53:51 2014
@@ -0,0 +1,16 @@
+// RUN: %clangxx -O0 %s -o %t && %run %t
+// XFAIL: lsan
+
+#include <assert.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+int main() {
+ struct rlimit lim_core;
+ getrlimit(RLIMIT_CORE, &lim_core);
+ void *p;
+ if (sizeof(p) == 8) {
+ assert(0 == lim_core.rlim_max);
+ }
+ return 0;
+}
More information about the llvm-commits
mailing list