[llvm-commits] [compiler-rt] r164018 - /compiler-rt/trunk/lib/asan/asan_report.cc

Alexey Samsonov samsonov at google.com
Mon Sep 17 01:02:20 PDT 2012


Author: samsonov
Date: Mon Sep 17 03:02:19 2012
New Revision: 164018

URL: http://llvm.org/viewvc/llvm-project?rev=164018&view=rev
Log:
[ASan] increase sleep time if ASan finds two bugs simultaneously to make sure full error report is printed

Modified:
    compiler-rt/trunk/lib/asan/asan_report.cc

Modified: compiler-rt/trunk/lib/asan/asan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=164018&r1=164017&r2=164018&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_report.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_report.cc Mon Sep 17 03:02:19 2012
@@ -229,27 +229,33 @@
  public:
   ScopedInErrorReport() {
     static atomic_uint32_t num_calls;
+    static u32 reporting_thread_tid;
     if (atomic_fetch_add(&num_calls, 1, memory_order_relaxed) != 0) {
       // Do not print more than one report, otherwise they will mix up.
       // Error reporting functions shouldn't return at this situation, as
       // they are defined as no-return.
       Report("AddressSanitizer: while reporting a bug found another one."
                  "Ignoring.\n");
-      // We can't use infinite busy loop here, as ASan may try to report an
-      // error while another error report is being printed (e.g. if the code
-      // that prints error report for buffer overflow results in SEGV).
-      SleepForSeconds(Max(5, flags()->sleep_before_dying + 1));
+      u32 current_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
+      if (current_tid != reporting_thread_tid) {
+        // ASan found two bugs in different threads simultaneously. Sleep
+        // long enough to make sure that the thread which started to print
+        // an error report will finish doing it.
+        SleepForSeconds(Max(100, flags()->sleep_before_dying + 1));
+      }
       Die();
     }
     if (on_error_callback) {
       on_error_callback();
     }
+    reporting_thread_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
     Printf("===================================================="
-               "=============\n");
-    AsanThread *curr_thread = asanThreadRegistry().GetCurrent();
-    if (curr_thread) {
+           "=============\n");
+    if (reporting_thread_tid != kInvalidTid) {
       // We started reporting an error message. Stop using the fake stack
       // in case we call an instrumented function from a symbolizer.
+      AsanThread *curr_thread = asanThreadRegistry().GetCurrent();
+      CHECK(curr_thread);
       curr_thread->fake_stack().StopUsingFakeStack();
     }
   }





More information about the llvm-commits mailing list