[compiler-rt] fc545c5 - tsan: handle bugs in symbolizer more gracefully

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 07:53:19 PDT 2021


Author: Dmitry Vyukov
Date: 2021-08-05T16:53:15+02:00
New Revision: fc545c52cdfe1593967598ac9c3645095d5405c6

URL: https://github.com/llvm/llvm-project/commit/fc545c52cdfe1593967598ac9c3645095d5405c6
DIFF: https://github.com/llvm/llvm-project/commit/fc545c52cdfe1593967598ac9c3645095d5405c6.diff

LOG: tsan: handle bugs in symbolizer more gracefully

For symbolizer we only process SIGSEGV signals synchronously
(which means bug in symbolizer or in tsan).
But we still want to reset in_symbolizer to fail gracefully.
Symbolizer and user code use different memory allocators,
so if we don't reset in_symbolizer we can get memory allocated
with one being feed with another, which can cause more crashes.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D107564

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index e3a5738a7ffd..cd97f60ccf62 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -1956,11 +1956,19 @@ static void CallUserSignalHandler(ThreadState *thr, bool sync, bool acquire,
   int ignore_reads_and_writes = thr->ignore_reads_and_writes;
   int ignore_interceptors = thr->ignore_interceptors;
   int ignore_sync = thr->ignore_sync;
+  // For symbolizer we only process SIGSEGVs synchronously
+  // (bug in symbolizer or in tsan). But we want to reset
+  // in_symbolizer to fail gracefully. Symbolizer and user code
+  // use 
diff erent memory allocators, so if we don't reset
+  // in_symbolizer we can get memory allocated with one being
+  // feed with another, which can cause more crashes.
+  int in_symbolizer = thr->in_symbolizer;
   if (!ctx->after_multithreaded_fork) {
     thr->ignore_reads_and_writes = 0;
     thr->fast_state.ClearIgnoreBit();
     thr->ignore_interceptors = 0;
     thr->ignore_sync = 0;
+    thr->in_symbolizer = 0;
   }
   // Ensure that the handler does not spoil errno.
   const int saved_errno = errno;
@@ -1979,6 +1987,7 @@ static void CallUserSignalHandler(ThreadState *thr, bool sync, bool acquire,
       thr->fast_state.SetIgnoreBit();
     thr->ignore_interceptors = ignore_interceptors;
     thr->ignore_sync = ignore_sync;
+    thr->in_symbolizer = in_symbolizer;
   }
   // We do not detect errno spoiling for SIGTERM,
   // because some SIGTERM handlers do spoil errno but reraise SIGTERM,


        


More information about the llvm-commits mailing list