<br><br><div class="gmail_quote">On Wed, Aug 29, 2012 at 12:54 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div><div class="h5">On Wed, Aug 29, 2012 at 12:50 PM, 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">

<div class="gmail_extra"><div class="gmail_quote"><div><div>On Wed, Aug 29, 2012 at 12:40 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@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: kcc<br>
Date: Wed Aug 29 03:40:36 2012<br>
New Revision: 162834<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=162834&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=162834&view=rev</a><br>
Log:<br>
[asan/tsan] use InternalScopedBuffer instead of stack arrays. Use mmap inseted of InternalAlloc in InternalScopedBuffer<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc<br>
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_stacktrace.cc<br>
<br>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=162834&r1=162833&r2=162834&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=162834&r1=162833&r2=162834&view=diff</a><br>



==============================================================================<br>
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)<br>
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Wed Aug 29 03:40:36 2012<br>
@@ -55,15 +55,17 @@<br>
<br>
 // InternalScopedBuffer can be used instead of large stack arrays to<br>
 // keep frame size low.<br>
+// FIXME: use InternalAlloc instead of MmapOrDie once<br>
+// InternalAlloc is made libc-free.<br>
 template<typename T><br>
 class InternalScopedBuffer {<br>
  public:<br>
   explicit InternalScopedBuffer(uptr cnt) {<br>
     cnt_ = cnt;<br>
-    ptr_ = (T*)InternalAlloc(cnt * sizeof(T));<br>
+    ptr_ = (T*)MmapOrDie(cnt * sizeof(T), "InternalScopedBuffer");<br></blockquote><div><br></div><div><br></div></div></div><div>Please make it using malloc again. It was always intended to be "scoped-malloc" and extensively used in tsan.</div>
</div></div></blockquote></div></div></div></blockquote><div><br></div><div>Note that we've encountered the problem on Android where __libc_malloc is still calling our interceptors for malloc.</div><div>AFAIR this behavior would crash TSan (if we ever decide to port it).</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div class="h5"><div><br></div></div></div><div>We can not use libc malloc in asan and should not use it in tsan either. </div>
<div>So, we either need to have two variants of InternalScopedBuffer, or we need to fix InternalAlloca to not depend on libc. </div>
<div>The former is simpler, the latter is better. </div><div>Thoughts? </div></div></blockquote><div><br></div><div>This depends on how "good" and efficient our InternalAlloc should be (that is, how difficult would it be to implement</div>
<div>yet another allocator, gr-r-r). For code in sanitizer_common/ we're probably not that interested in efficiency. Can't tell for tsan.</div></div><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>