diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-12-17 11:15:39 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-12-17 11:15:39 +0000 |
commit | 6bd601b5267bff1c7ce5f69815cd59d0a4cd0576 (patch) | |
tree | 6c6179f647425f8be8c75b9aa4e94e3ab2668c51 | |
parent | bb6f93683ef9e9d87b2ff912af651e0ea0e3abd2 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197491 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_rtl.cc | 7 | ||||
-rw-r--r-- | lib/lsan/lit_tests/TestCases/suppressions_file.cc | 9 | ||||
-rw-r--r-- | lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp | 1 | ||||
-rw-r--r-- | lib/lsan/lsan.cc | 7 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_flags.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_flags.h | 6 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer.h | 4 | ||||
-rw-r--r-- | lib/tsan/tests/unit/tsan_flags_test.cc | 2 |
8 files changed, 18 insertions, 20 deletions
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 7738836a3..60571fd31 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -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. diff --git a/lib/lsan/lit_tests/TestCases/suppressions_file.cc b/lib/lsan/lit_tests/TestCases/suppressions_file.cc index 59dab8981..bc8913a6c 100644 --- a/lib/lsan/lit_tests/TestCases/suppressions_file.cc +++ b/lib/lsan/lit_tests/TestCases/suppressions_file.cc @@ -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> diff --git a/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp b/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp deleted file mode 100644 index 8d8e560cb..000000000 --- a/lib/lsan/lit_tests/TestCases/suppressions_file.cc.supp +++ /dev/null @@ -1 +0,0 @@ -leak:*LSanTestLeakingFunc* diff --git a/lib/lsan/lsan.cc b/lib/lsan/lsan.cc index 203590eb7..1b30b4f74 100644 --- a/lib/lsan/lsan.cc +++ b/lib/lsan/lsan.cc @@ -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) diff --git a/lib/sanitizer_common/sanitizer_flags.cc b/lib/sanitizer_common/sanitizer_flags.cc index 4fb713c0f..b817cc82a 100644 --- a/lib/sanitizer_common/sanitizer_flags.cc +++ b/lib/sanitizer_common/sanitizer_flags.cc @@ -52,6 +52,8 @@ void ParseCommonFlagsFromString(CommonFlags *f, const char *str) { // 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, diff --git a/lib/sanitizer_common/sanitizer_flags.h b/lib/sanitizer_common/sanitizer_flags.h index ffc69fe18..34584f443 100644 --- a/lib/sanitizer_common/sanitizer_flags.h +++ b/lib/sanitizer_common/sanitizer_flags.h @@ -23,10 +23,12 @@ void ParseFlag(const char *env, int *flag, const char *name); 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; diff --git a/lib/sanitizer_common/sanitizer_symbolizer.h b/lib/sanitizer_common/sanitizer_symbolizer.h index 886fed20d..f2e8f4475 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/lib/sanitizer_common/sanitizer_symbolizer.h @@ -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_; diff --git a/lib/tsan/tests/unit/tsan_flags_test.cc b/lib/tsan/tests/unit/tsan_flags_test.cc index ef2222431..2e0a7d1b7 100644 --- a/lib/tsan/tests/unit/tsan_flags_test.cc +++ b/lib/tsan/tests/unit/tsan_flags_test.cc @@ -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); |