From 140cd8415550856418f47aa3f416ffb014daad16 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Thu, 14 Mar 2013 10:07:40 +0000 Subject: [PATCH] [ASan] make ASan assume ASAN_OPTIONS=symbolize=1 if ASAN_EXTERNAL_SYMBOLIZER is defined llvm-svn: 177036 --- compiler-rt/lib/asan/asan_rtl.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index d7aebd4..9c17145 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -130,11 +130,13 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->strict_memcmp, "strict_memcmp"); } +static const char *asan_external_symbolizer; + void InitializeFlags(Flags *f, const char *env) { internal_memset(f, 0, sizeof(*f)); f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28; - f->symbolize = false; + f->symbolize = (asan_external_symbolizer != 0); f->verbosity = 0; f->redzone = ASAN_ALLOCATOR_VERSION == 2 ? 16 : (ASAN_LOW_MEMORY) ? 64 : 128; f->debug = false; @@ -426,6 +428,8 @@ void __asan_init() { SetCheckFailedCallback(AsanCheckFailed); SetPrintfAndReportCallback(AppendToErrorMessageBuffer); + // Check if external symbolizer is defined before parsing the flags. + asan_external_symbolizer = GetEnv("ASAN_SYMBOLIZER_PATH"); // Initialize flags. This must be done early, because most of the // initialization steps look at flags(). const char *options = GetEnv("ASAN_OPTIONS"); @@ -503,11 +507,9 @@ void __asan_init() { InstallSignalHandlers(); // Start symbolizer process if necessary. - if (flags()->symbolize) { - const char *external_symbolizer = GetEnv("ASAN_SYMBOLIZER_PATH"); - if (external_symbolizer) { - InitializeExternalSymbolizer(external_symbolizer); - } + if (flags()->symbolize && asan_external_symbolizer && + asan_external_symbolizer[0]) { + InitializeExternalSymbolizer(asan_external_symbolizer); } // On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited -- 2.7.4