[compiler-rt] r214006 - [UBSan] Initialize symbolizer inside __ubsan::Init().

Alexey Samsonov vonosmas at gmail.com
Fri Jul 25 18:41:45 PDT 2014


Author: samsonov
Date: Fri Jul 25 20:41:45 2014
New Revision: 214006

URL: http://llvm.org/viewvc/llvm-project?rev=214006&view=rev
Log:
[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.

Modified:
    compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
    compiler-rt/trunk/lib/ubsan/ubsan_init.cc

Modified: compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag.cc?rev=214006&r1=214005&r2=214006&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_diag.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_diag.cc Fri Jul 25 20:41:45 2014
@@ -63,8 +63,8 @@ Location __ubsan::getFunctionLocation(up
   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 *Messa
         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:

Modified: compiler-rt/trunk/lib/ubsan/ubsan_init.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_init.cc?rev=214006&r1=214005&r2=214006&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_init.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_init.cc Fri Jul 25 20:41:45 2014
@@ -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();





More information about the llvm-commits mailing list