From e87e5ce5d687a7f1223faa652add3b3b937ae30f Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Sat, 26 Jul 2014 01:41:45 +0000 Subject: [PATCH] [UBSan] Initialize symbolizer inside __ubsan::Init(). We used to initialize symbolizer lazily, but this doesn't work in various sandboxed environments. Instead, let's be consistent with the rest of sanitizers. llvm-svn: 214006 --- compiler-rt/lib/ubsan/ubsan_diag.cc | 6 +++--- compiler-rt/lib/ubsan/ubsan_init.cc | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/ubsan/ubsan_diag.cc b/compiler-rt/lib/ubsan/ubsan_diag.cc index 87beb62..a8f2a49 100644 --- a/compiler-rt/lib/ubsan/ubsan_diag.cc +++ b/compiler-rt/lib/ubsan/ubsan_diag.cc @@ -63,8 +63,8 @@ Location __ubsan::getFunctionLocation(uptr Loc, const char **FName) { InitIfNecessary(); AddressInfo Info; - if (!Symbolizer::GetOrInit()->SymbolizePC(Loc, &Info, 1) || - !Info.module || !*Info.module) + if (!Symbolizer::Get()->SymbolizePC(Loc, &Info, 1) || !Info.module || + !*Info.module) return Location(Loc); if (FName && Info.function) @@ -148,7 +148,7 @@ static void renderText(const char *Message, const Diag::Arg *Args) { Printf("%s", A.String); break; case Diag::AK_Mangled: { - Printf("'%s'", Symbolizer::GetOrInit()->Demangle(A.String)); + Printf("'%s'", Symbolizer::Get()->Demangle(A.String)); break; } case Diag::AK_SInt: diff --git a/compiler-rt/lib/ubsan/ubsan_init.cc b/compiler-rt/lib/ubsan/ubsan_init.cc index 9cfd42f..79f28c9 100644 --- a/compiler-rt/lib/ubsan/ubsan_init.cc +++ b/compiler-rt/lib/ubsan/ubsan_init.cc @@ -17,6 +17,7 @@ #include "sanitizer_common/sanitizer_libc.h" #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_mutex.h" +#include "sanitizer_common/sanitizer_symbolizer.h" using namespace __ubsan; @@ -42,6 +43,7 @@ void __ubsan::InitIfNecessary() { cf->print_summary = false; // Common flags may only be modified via UBSAN_OPTIONS. ParseCommonFlagsFromString(cf, GetEnv("UBSAN_OPTIONS")); + Symbolizer::GetOrInit(); } // Initialize UBSan-specific flags. InitializeFlags(); -- 2.7.4