Looks good now (assuming the tests pass). <div>Thanks! </div><div><br></div><div>--kcc <br><br><div class="gmail_quote">On Thu, Apr 5, 2012 at 10:10 AM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com">samsonov@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 class="im">On Thu, Apr 5, 2012 at 8:48 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>On Thu, Apr 5, 2012 at 9:38 AM,  <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@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>On 2012/04/05 16:25:08, kcc1 wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Oh, I mean that asan_new_delete.cc should be a part of asan rtl.<br>
Isn't that enough?<br>
</blockquote>
<br></div>
No, if ASan RTL doesn't depend on anything in asan_new_delete.cc.<br></blockquote><div><br></div></div><div>We know how to fix it. </div><div>Juts make an empty InitNewAndDelete() and call it from another file.</div>

</div></blockquote><div><br></div></div><div>It's in the patch already.</div><div><div class="h5"><div> </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>
<div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
asan_new_delete.o will be archived into libasan .a but will not be<br>
statically linked into the exe file which contains a call to "new"<br>
(if we're unlucky, e.g. if libstdc++ is linked earlier).<div><div><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Apr 5, 2012 at 8:46 AM, <mailto:<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>> wrote:<br>
</blockquote>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> On 2012/04/04 14:57:48, kcc1 wrote:<br>
><br>
>> I'd prefer to move our custom new/delete into asan_new_delete.cc,<br>
</blockquote>
and<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>><br>
> in<br>
><br>
>> that file it would probably be ok to include <new>.<br>
>><br>
><br>
> Yep, that's reasonable, but we have to make sure that resulting<br>
> asan_new_delete.o will be loaded from libasan .a file<br>
> (otherwise our "new" implementation is just not linked into exe, and<br>
> dynamic linker chooses libstdc++ implementation).<br>
><br>
> We can<br>
> 1) add a fake dependency between asan_rtl and asan_new_delete (in<br>
</blockquote>
this<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> CL, a bit hacky)<br>
> 2) hack lib/Driver/Tools.cpp and make sure that flag -lstdc++ is<br>
</blockquote>
passed<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> to ld after .a with ASan RT (it is currently passed before). (looks<br>
</blockquote>
more<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> hacky)<br>
> 3) use -Wl,--whole-archive (omg).<br>
><br>
><br>
>  --kcc<br>
>><br>
><br>
>  On Wed, Apr 4, 2012 at 7:53 AM, <mailto:<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>> wrote:<br>
>><br>
><br>
>  > Reviewers: kcc1, timurrrr_at_google_com,<br>
>> ><br>
>> > Message:<br>
>> > #include <new> brings a number of system libraries (e.g.<br>
</blockquote>
<string.h><br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
>><br>
> on<br>
><br>
>> > Windows), which is probably unwanted. We (hopefully) can replace<br>
>> > std::nothrow_t and std::bad_alloc by custom stubs, so that our<br>
>><br>
> overload<br>
><br>
>> > of new would still work in a user program.<br>
>> ><br>
>> ><br>
>> ><br>
>> > Please review this at<br>
>><br>
><br></div></div>
> <a href="http://codereview.appspot.com/****5966077/%253Chttp://**" target="_blank">http://codereview.appspot.com/<u></u>****5966077/%253Chttp://**</a><br>
><br>
</blockquote>
<br>
<a href="http://codereview.appspot.com/**5966077/" target="_blank">codereview.appspot.com/**<u></u>5966077/</a><<a href="http://codereview.appspot.com/**5966077/%3Chttp://codereview.appspot.com/5966077/" target="_blank">http://codereview.<u></u>appspot.com/**5966077/%3Chttp:<u></u>//codereview.appspot.com/<u></u>5966077/</a>><br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
> ><br>
><br>
>  ><br>
>> > Affected files:<br>
>> >  M     asan_interceptors.cc<br>
>> ><br>
>> ><br>
>> > Index: asan_interceptors.cc<br>
>> ><br>
>><br></div>
> ==============================<u></u>****==========================<u></u>==**<div><br>
> ==**=======<br>
><br>
>  > --- asan_interceptors.cc        (revision 154006)<br>
>> > +++ asan_interceptors.cc        (working copy)<br>
>> > @@ -22,8 +22,6 @@<br>
>> >  #include "asan_thread_registry.h"<br>
>> >  #include "interception/interception.h"<br>
>> ><br>
>> > -#include <new><br>
>> > -<br>
>> >  // Use macro to describe if specific function should be<br>
>> >  // intercepted on a given platform.<br>
>> >  #if !defined(_WIN32)<br>
>> > @@ -331,6 +329,10 @@<br>
>> >  void *operator new(size_t size) { OPERATOR_NEW_BODY; }<br>
>> >  void *operator new[](size_t size) { OPERATOR_NEW_BODY; }<br>
>> >  #else<br>
>> > +namespace std {<br>
>> > +class bad_alloc {};<br>
>> > +class nothrow_t;<br>
>> > +}  // namespace std<br>
>> >  void *operator new(size_t size) throw(std::bad_alloc) {<br>
>> > OPERATOR_NEW_BODY; }<br>
>> >  void *operator new[](size_t size) throw(std::bad_alloc) {<br>
>> > OPERATOR_NEW_BODY; }<br>
>> >  void *operator new(size_t size, std::nothrow_t const&) throw()<br>
>> ><br>
>> ><br>
>> ><br>
>><br>
><br>
><br>
><br>
><br>
</div></blockquote>
<br>
<a href="http://codereview.appspot.com/**5966077/%3Chttp://codereview.appspot.com/5966077/" target="_blank">http://codereview.appspot.com/<u></u>**5966077/%3Chttp://<u></u>codereview.appspot.com/<u></u>5966077/</a>><br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
><br>
</blockquote>
<br>
<br>
<br>
<a href="http://codereview.appspot.com/5966077/" target="_blank">http://codereview.appspot.com/<u></u>5966077/</a><br>
</blockquote></div></div></div><br>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</font></span></blockquote></div><br></div>