<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 14, 2013 at 11:21 AM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com" target="_blank">glider@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Why don't you make it is_in_runtime_library?</p></blockquote><div style>There is not much happening inside msan-rt (unlike asan/tsan),</div>
<div style>so I chose the name that reflects the actual usage, not a potential extension of it. </div><div style><br></div><div style>--kcc </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Feb 13, 2013 11:21 AM, "Kostya Serebryany" <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Author: kcc<br>
Date: Wed Feb 13 01:19:47 2013<br>
New Revision: 175040<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=175040&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=175040&view=rev</a><br>
Log:<br>
[msan] don't check shadow inside interceptors if we are inside symbolizer; add weak function __msan_default_options that overrides default options<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/msan/msan.cc<br>
    compiler-rt/trunk/lib/msan/msan.h<br>
    compiler-rt/trunk/lib/msan/msan_interceptors.cc<br>
    compiler-rt/trunk/lib/msan/msan_interface_internal.h<br>
    compiler-rt/trunk/lib/msan/msan_report.cc<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=175040&r1=175039&r2=175040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=175040&r1=175039&r2=175040&view=diff</a><br>


==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/msan.cc Wed Feb 13 01:19:47 2013<br>
@@ -58,6 +58,8 @@ static THREADLOCAL struct {<br>
   uptr stack_top, stack_bottom;<br>
 } __msan_stack_bounds;<br>
<br>
+static THREADLOCAL bool is_in_symbolizer;<br>
+<br>
 extern "C" const int __msan_track_origins;<br>
 int __msan_get_track_origins() {<br>
   return __msan_track_origins;<br>
@@ -81,6 +83,10 @@ static bool IsRunningUnderDr() {<br>
   return result;<br>
 }<br>
<br>
+void EnterSymbolizer() { is_in_symbolizer = true; }<br>
+void ExitSymbolizer()  { is_in_symbolizer = false; }<br>
+bool IsInSymbolizer() { return is_in_symbolizer; }<br>
+<br>
 static Flags msan_flags;<br>
<br>
 Flags *flags() {<br>
@@ -126,6 +132,9 @@ static void InitializeFlags(Flags *f, co<br>
   f->verbosity = 0;<br>
   f->strip_path_prefix = "";<br>
<br>
+  // Override from user-specified string.<br>
+  if (__msan_default_options)<br>
+    ParseFlagsFromString(f, __msan_default_options());<br>
   ParseFlagsFromString(f, options);<br>
 }<br>
<br>
@@ -417,3 +426,11 @@ u32 __msan_get_origin(void *a) {<br>
 u32 __msan_get_umr_origin() {<br>
   return __msan_origin_tls;<br>
 }<br>
+<br>
+#if !SANITIZER_SUPPORTS_WEAK_HOOKS<br>
+extern "C" {<br>
+SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE<br>
+const char* __msan_default_options() { return ""; }<br>
+}  // extern "C"<br>
+#endif<br>
+<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=175040&r1=175039&r2=175040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.h?rev=175040&r1=175039&r2=175040&view=diff</a><br>


==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan.h (original)<br>
+++ compiler-rt/trunk/lib/msan/msan.h Wed Feb 13 01:19:47 2013<br>
@@ -46,6 +46,10 @@ void InstallTrapHandler();<br>
 void InstallAtExitHandler();<br>
 void ReplaceOperatorsNewAndDelete();<br>
<br>
+void EnterSymbolizer();<br>
+void ExitSymbolizer();<br>
+bool IsInSymbolizer();<br>
+<br>
 void MsanDie();<br>
 void PrintWarning(uptr pc, uptr bp);<br>
 void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin);<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=175040&r1=175039&r2=175040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=175040&r1=175039&r2=175040&view=diff</a><br>


==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Wed Feb 13 01:19:47 2013<br>
@@ -41,6 +41,7 @@ using namespace __msan;<br>
 #define CHECK_UNPOISONED(x, n) \<br>
   do { \<br>
     sptr offset = __msan_test_shadow(x, n);                 \<br>
+    if (__msan::IsInSymbolizer()) break;                    \<br>
     if (offset >= 0 && flags()->report_umrs) {              \<br>
       GET_CALLER_PC_BP_SP;                                  \<br>
       (void)sp;                                             \<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan_interface_internal.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interface_internal.h?rev=175040&r1=175039&r2=175040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interface_internal.h?rev=175040&r1=175039&r2=175040&view=diff</a><br>


==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan_interface_internal.h (original)<br>
+++ compiler-rt/trunk/lib/msan/msan_interface_internal.h Wed Feb 13 01:19:47 2013<br>
@@ -85,6 +85,9 @@ void __msan_set_exit_code(int exit_code)<br>
 SANITIZER_INTERFACE_ATTRIBUTE<br>
 int __msan_set_poison_in_malloc(int do_poison);<br>
<br>
+SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE<br>
+/* OPTIONAL */ const char* __msan_default_options();<br>
+<br>
 // For testing.<br>
 SANITIZER_INTERFACE_ATTRIBUTE<br>
 void __msan_set_expect_umr(int expect_umr);<br>
<br>
Modified: compiler-rt/trunk/lib/msan/msan_report.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=175040&r1=175039&r2=175040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=175040&r1=175039&r2=175040&view=diff</a><br>


==============================================================================<br>
--- compiler-rt/trunk/lib/msan/msan_report.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/msan_report.cc Wed Feb 13 01:19:47 2013<br>
@@ -44,6 +44,16 @@ class Decorator: private __sanitizer::An<br>
   const char *End()    { return Default(); }<br>
 };<br>
<br>
+struct SymbolizerScope {<br>
+  SymbolizerScope() { EnterSymbolizer(); }<br>
+  ~SymbolizerScope() { ExitSymbolizer(); }<br>
+};<br>
+<br>
+static void PrintStack(const uptr *trace, uptr size) {<br>
+  SymbolizerScope sym_scope;<br>
+  StackTrace::PrintStack(trace, size, true, flags()->strip_path_prefix, 0);<br>
+}<br>
+<br>
 static void DescribeOrigin(u32 origin) {<br>
   Decorator d;<br>
   if (flags()->verbosity)<br>
@@ -64,7 +74,7 @@ static void DescribeOrigin(u32 origin) {<br>
     const uptr *trace = StackDepotGet(origin, &size);<br>
     Printf("  %sUninitialized value was created by a heap allocation%s\n",<br>
            d.Origin(), d.End());<br>
-    StackTrace::PrintStack(trace, size, true, flags()->strip_path_prefix, 0);<br>
+    PrintStack(trace, size);<br>
   }<br>
 }<br>
<br>
@@ -72,7 +82,10 @@ static void ReportSummary(const char *er<br>
   if (!stack->size || !IsSymbolizerAvailable()) return;<br>
   AddressInfo ai;<br>
   uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]);<br>
-  SymbolizeCode(pc, &ai, 1);<br>
+  {<br>
+    SymbolizerScope sym_scope;<br>
+    SymbolizeCode(pc, &ai, 1);<br>
+  }<br>
   ReportErrorSummary(error_type,<br>
                      StripPathPrefix(ai.file, flags()->strip_path_prefix),<br>
                      ai.line, ai.function);<br>
@@ -87,8 +100,7 @@ void ReportUMR(StackTrace *stack, u32 or<br>
   Printf("%s", d.Warning());<br>
   Report(" WARNING: Use of uninitialized value\n");<br>
   Printf("%s", d.End());<br>
-  StackTrace::PrintStack(stack->trace, stack->size, true,<br>
-                         flags()->strip_path_prefix, 0);<br>
+  PrintStack(stack->trace, stack->size);<br>
   if (origin) {<br>
     DescribeOrigin(origin);<br>
   }<br>
@@ -99,8 +111,7 @@ void ReportExpectedUMRNotFound(StackTrac<br>
   GenericScopedLock<StaticSpinMutex> lock(&report_mu);<br>
<br>
   Printf(" WARNING: Expected use of uninitialized value not found\n");<br>
-  StackTrace::PrintStack(stack->trace, stack->size, true,<br>
-                         flags()->strip_path_prefix, 0);<br>
+  PrintStack(stack->trace, stack->size);<br>
 }<br>
<br>
 void ReportAtExitStatistics() {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div></div>