[compiler-rt] r197491 - [Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).

Alexey Samsonov samsonov at google.com
Tue Dec 17 03:15:40 PST 2013


Author: samsonov
Date: Tue Dec 17 05:15:39 2013
New Revision: 197491

URL: http://llvm.org/viewvc/llvm-project?rev=197491&view=rev
Log:
[Sanitizer] Always initialize a Symbolizer (even if 'symbolize' is false).

If 'symbolize' flag is not set, we still want to transform virtual address
to module+offset pair in the call to Symbolizer::SymbolizeCode().
See https://code.google.com/p/address-sanitizer/issues/detail?id=251 for
more details.

Removed:
    compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp
Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc
    compiler-rt/trunk/lib/lsan/lsan.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
    compiler-rt/trunk/lib/tsan/tests/unit/tsan_flags_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Dec 17 05:15:39 2013
@@ -534,12 +534,7 @@ void __asan_init() {
   // fork() on Mac locks the allocator.
   InitializeAllocator();
 
-  // Start symbolizer process if necessary.
-  if (common_flags()->symbolize) {
-    Symbolizer::Init(common_flags()->external_symbolizer_path);
-  } else {
-    Symbolizer::Disable();
-  }
+  Symbolizer::Init(common_flags()->external_symbolizer_path);
 
   // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited
   // should be set to 1 prior to initializing the threads.

Modified: compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc Tue Dec 17 05:15:39 2013
@@ -1,6 +1,11 @@
-// RUN: LSAN_BASE="use_registers=0:use_stacks=0:suppressions=%s.supp"
+// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
 // RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s
+
+// RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp1
+// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 not %t 2>&1 | FileCheck %s
+
+// RUN: echo "leak:%t" > %t.supp2
+// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false %t
 
 #include <stdio.h>
 #include <stdlib.h>

Removed: compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp?rev=197490&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp (removed)
@@ -1 +0,0 @@
-leak:*LSanTestLeakingFunc*

Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Tue Dec 17 05:15:39 2013
@@ -60,12 +60,7 @@ extern "C" void __lsan_init() {
   ThreadStart(tid, GetTid());
   SetCurrentThread(tid);
 
-  // Start symbolizer process if necessary.
-  if (common_flags()->symbolize) {
-    Symbolizer::Init(common_flags()->external_symbolizer_path);
-  } else {
-    Symbolizer::Disable();
-  }
+  Symbolizer::Init(common_flags()->external_symbolizer_path);
 
   InitCommonLsan();
   if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Tue Dec 17 05:15:39 2013
@@ -52,6 +52,8 @@ void ParseCommonFlagsFromString(CommonFl
   // Do a sanity check for certain flags.
   if (f->malloc_context_size < 1)
     f->malloc_context_size = 1;
+  if (!f->symbolize)
+    f->external_symbolizer_path = "";
 }
 
 static bool GetFlagValue(const char *env, const char *name,

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h Tue Dec 17 05:15:39 2013
@@ -23,10 +23,12 @@ void ParseFlag(const char *env, int *fla
 void ParseFlag(const char *env, const char **flag, const char *name);
 
 struct CommonFlags {
-  // If set, use the online symbolizer from common sanitizer runtime.
+  // If set, use the online symbolizer from common sanitizer runtime to turn
+  // virtual addresses to file/line locations.
   bool symbolize;
   // Path to external symbolizer. If it is NULL, symbolizer will be looked for
-  // in PATH. If it is empty, external symbolizer will not be started.
+  // in PATH. If it is empty (or if "symbolize" is false), external symbolizer
+  // will not be started.
   const char *external_symbolizer_path;
   // Strips this prefix from file paths in error reports.
   const char *strip_path_prefix;

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h Tue Dec 17 05:15:39 2013
@@ -79,8 +79,6 @@ class Symbolizer {
   /// reasons as this function will check $PATH for an external symbolizer.  Not
   /// thread safe.
   static Symbolizer *Init(const char* path_to_external = 0);
-  /// Initialize the symbolizer in a disabled state.  Not thread safe.
-  static Symbolizer *Disable();
   // Fills at most "max_frames" elements of "frames" with descriptions
   // for a given address (in all inlined functions). Returns the number
   // of descriptions actually filled.
@@ -121,6 +119,8 @@ class Symbolizer {
   /// Create a symbolizer and store it to symbolizer_ without checking if one
   /// already exists.  Not thread safe.
   static Symbolizer *CreateAndStore(const char *path_to_external);
+  /// Initialize the symbolizer in a disabled state.  Not thread safe.
+  static Symbolizer *Disable();
 
   static Symbolizer *symbolizer_;
   static StaticSpinMutex init_mu_;

Modified: compiler-rt/trunk/lib/tsan/tests/unit/tsan_flags_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/tests/unit/tsan_flags_test.cc?rev=197491&r1=197490&r2=197491&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/tests/unit/tsan_flags_test.cc (original)
+++ compiler-rt/trunk/lib/tsan/tests/unit/tsan_flags_test.cc Tue Dec 17 05:15:39 2013
@@ -145,7 +145,7 @@ void VerifyOptions1(Flags *f) {
   EXPECT_EQ(f->io_sync, 1);
 
   EXPECT_EQ(f->symbolize, 0);
-  EXPECT_EQ(f->external_symbolizer_path, std::string("asdfgh"));
+  EXPECT_EQ(f->external_symbolizer_path, std::string(""));
   EXPECT_EQ(f->strip_path_prefix, std::string("zxcvb"));
   EXPECT_EQ(f->fast_unwind_on_fatal, 0);
   EXPECT_EQ(f->fast_unwind_on_malloc, 0);





More information about the llvm-commits mailing list