[UBSan] Initialize symbolizer inside __ubsan::Init().
authorAlexey Samsonov <vonosmas@gmail.com>
Sat, 26 Jul 2014 01:41:45 +0000 (01:41 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Sat, 26 Jul 2014 01:41:45 +0000 (01:41 +0000)
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
compiler-rt/lib/ubsan/ubsan_init.cc

index 87beb62..a8f2a49 100644 (file)
@@ -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:
index 9cfd42f..79f28c9 100644 (file)
@@ -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();