<div dir="ltr">What's the reason to introduce a copy of a flag instead of using the common one as asan/msan do? </div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 27, 2013 at 6:31 AM, Dmitry Vyukov <span dir="ltr"><<a href="mailto:dvyukov@google.com" target="_blank">dvyukov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dvyukov<br>
Date: Thu Sep 26 21:31:23 2013<br>
New Revision: 191482<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191482&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=191482&view=rev</a><br>
Log:<br>
tsan: support allocator_may_return_null flag<br>
Fixes <a href="https://code.google.com/p/thread-sanitizer/issues/detail?id=29" target="_blank">https://code.google.com/p/thread-sanitizer/issues/detail?id=29</a><br>
<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc<br>
    compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc?rev=191482&r1=191481&r2=191482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc?rev=191482&r1=191481&r2=191482&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc (original)<br>
+++ compiler-rt/trunk/lib/tsan/lit_tests/malloc_overflow.cc Thu Sep 26 21:31:23 2013<br>
@@ -1,5 +1,3 @@<br>
-// XFAIL: *<br>
-// FIXME: <a href="https://code.google.com/p/thread-sanitizer/issues/detail?id=29" target="_blank">https://code.google.com/p/thread-sanitizer/issues/detail?id=29</a><br>
 // RUN: %clangxx_tsan -O1 %s -o %t<br>
 // RUN: TSAN_OPTIONS=allocator_may_return_null=1 %t 2>&1 | FileCheck %s<br>
 #include <stdio.h><br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=191482&r1=191481&r2=191482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=191482&r1=191481&r2=191482&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Thu Sep 26 21:31:23 2013<br>
@@ -64,6 +64,7 @@ void InitializeFlags(Flags *f, const cha<br>
   f->external_symbolizer_path = "";<br>
   f->history_size = kGoMode ? 1 : 2;  // There are a lot of goroutines in Go.<br>
   f->io_sync = 1;<br>
+  f->allocator_may_return_null = false;<br>
<br>
   // Let a frontend override.<br>
   OverrideFlags(f);<br>
@@ -95,6 +96,7 @@ void InitializeFlags(Flags *f, const cha<br>
   ParseFlag(env, &f->external_symbolizer_path, "external_symbolizer_path");<br>
   ParseFlag(env, &f->history_size, "history_size");<br>
   ParseFlag(env, &f->io_sync, "io_sync");<br>
+  ParseFlag(env, &f->allocator_may_return_null, "allocator_may_return_null");<br>
<br>
   if (!f->report_bugs) {<br>
     f->report_thread_leaks = false;<br>
@@ -113,6 +115,8 @@ void InitializeFlags(Flags *f, const cha<br>
            " (must be [0..2])\n");<br>
     Die();<br>
   }<br>
+<br>
+  common_flags()->allocator_may_return_null = f->allocator_may_return_null;<br>
 }<br>
<br>
 }  // namespace __tsan<br>
<br>
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h?rev=191482&r1=191481&r2=191482&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h?rev=191482&r1=191481&r2=191482&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h (original)<br>
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h Thu Sep 26 21:31:23 2013<br>
@@ -92,6 +92,8 @@ struct Flags {<br>
   // 1 - reasonable level of synchronization (write->read)<br>
   // 2 - global synchronization of all IO operations<br>
   int io_sync;<br>
+  // If false, the allocator will crash instead of returning 0 on out-of-memory.<br>
+  bool allocator_may_return_null;<br>
 };<br>
<br>
 Flags *flags();<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">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><br></div>