[compiler-rt] r260717 - [LSan] Print more helpful error message if LSan crashes during leak detection.

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 12:20:51 PST 2016


Author: samsonov
Date: Fri Feb 12 14:20:51 2016
New Revision: 260717

URL: http://llvm.org/viewvc/llvm-project?rev=260717&view=rev
Log:
[LSan] Print more helpful error message if LSan crashes during leak detection.

Modified:
    compiler-rt/trunk/lib/lsan/lsan_common.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
    compiler-rt/trunk/test/asan/TestCases/Linux/leak_check_segv.cc

Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=260717&r1=260716&r2=260717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan_common.cc Fri Feb 12 14:20:51 2016
@@ -446,6 +446,9 @@ static bool CheckForLeaks() {
 
   if (!param.success) {
     Report("LeakSanitizer has encountered a fatal error.\n");
+    Report(
+        "HINT: For debugging, try setting environment variable "
+        "LSAN_OPTIONS=verbosity=1:log_threads=1\n");
     Die();
   }
   param.leak_report.ApplySuppressions();

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=260717&r1=260716&r2=260717&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc Fri Feb 12 14:20:51 2016
@@ -229,8 +229,8 @@ static void TracerThreadDieCallback() {
 // Signal handler to wake up suspended threads when the tracer thread dies.
 static void TracerThreadSignalHandler(int signum, void *siginfo, void *uctx) {
   SignalContext ctx = SignalContext::Create(siginfo, uctx);
-  VPrintf(1, "Tracer caught signal %d: addr=0x%zx pc=0x%zx sp=0x%zx\n",
-      signum, ctx.addr, ctx.pc, ctx.sp);
+  Printf("Tracer caught signal %d: addr=0x%zx pc=0x%zx sp=0x%zx\n", signum,
+         ctx.addr, ctx.pc, ctx.sp);
   ThreadSuspender *inst = thread_suspender_instance;
   if (inst) {
     if (signum == SIGABRT)

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/leak_check_segv.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/leak_check_segv.cc?rev=260717&r1=260716&r2=260717&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/leak_check_segv.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/leak_check_segv.cc Fri Feb 12 14:20:51 2016
@@ -1,5 +1,5 @@
 // Test that SIGSEGV during leak checking does not crash the process.
-// RUN: %clangxx_asan -O1 %s -o %t && LSAN_OPTIONS="verbosity=1" not %run %t 2>&1
+// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
 // REQUIRES: leak-detection
 #include <stdlib.h>
 #include <stdio.h>
@@ -11,7 +11,7 @@ char data[10 * 1024 * 1024];
 int main() {
   void *p = malloc(10 * 1024 * 1024);
   // surprise-surprise!
-  mprotect((void*)(((unsigned long)p + 4095) & ~4095), 16 * 1024, PROT_NONE); 
+  mprotect((void*)(((unsigned long)p + 4095) & ~4095), 16 * 1024, PROT_NONE);
   mprotect((void*)(((unsigned long)data + 4095) & ~4095), 16 * 1024, PROT_NONE);
   __lsan_do_leak_check();
   fprintf(stderr, "DONE\n");
@@ -19,5 +19,5 @@ int main() {
 
 // CHECK: Tracer caught signal 11
 // CHECK: LeakSanitizer has encountered a fatal error
+// CHECK: HINT: For debugging, try setting {{.*}} LSAN_OPTIONS
 // CHECK-NOT: DONE
-




More information about the llvm-commits mailing list