<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Sorry for delays...</span><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Unfortunately, we won't be able to find errors on globals from template instantiations - see <a href="https://code.google.com/p/address-sanitizer/issues/detail?id=215#c2" target="_blank">https://code.google.com/p/address-sanitizer/issues/detail?id=215#c2</a></div>
<div style="font-family:arial,sans-serif;font-size:13px">(tl;dr - we skip all globals with linkonce_odr linkage). Still, the patch looks reasonable and works on ASan test-suite with minor modifications.</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">I'll land after a bit more testing (e.g. to verify that we won't slow down the code horribly).</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, May 13, 2014 at 12:58 PM, Alexey Samsonov <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 dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="">On Tue, May 13, 2014 at 1:30 AM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">samsonov, do you want to try shepherding this in?</div></blockquote><div><br></div></div><div>Definitely. I'll try to test/land it this week.</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 dir="ltr"> The patch should work as-is and it's better than what's currently there, but maybe it should happen behind a flag at first (as it might find more stuff than the current logic) – not sure about this. And there should probably some integration test, like Reid mentioned.</div>

</blockquote><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 7, 2014 at 11:41 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@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 dir="ltr">No, it's more basic.<div><br></div><div>If I understand the current ASan init-order instrumentation, it only poisons globals of other TUs during _GLOBAL__*.  Initializers of static data members of class templates get their own llvm.global_ctors entry, so other globals are not poisoned, and we get false negatives.</div>



</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 7, 2014 at 12:46 AM, 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"><div dir="ltr">This is <a href="https://code.google.com/p/address-sanitizer/issues/detail?id=215" target="_blank">https://code.google.com/p/address-sanitizer/issues/detail?id=215</a>, isn't it? </div>



<div><div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, May 7, 2014 at 4:07 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@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 dir="ltr">This is a good idea, because it will catch more bugs.  Consider this C++:<div><br><div><div>int foo();</div><div>template <int N> struct X { static int x; };</div><div>template <int N> int X<N>::x = foo();</div>





<div>int main() { return X<0>::x + X<2>::x + X<3>::x + X<4>::x; }</div></div><div><br></div><div>This will put 4 entries into llvm.global_ctors, none of which are called _GLOBAL__*.  We should probably have an ASan integration test in compiler-rt for this, when foo accesses some global in a different TU.</div>





</div><div><br></div><div>On the other hand, all this poisoning and unpoisoning may be expensive.  We could batch up all the initializers of equal priority and merge them into one initializer bracketed by calls to poison and unpoison.</div>





</div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Tue, May 6, 2014 at 4:55 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br>





</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hi,<br>
<br>
here's how the global_ctors version would look. I haven't tested this<br>
much (it's different in that it could now instrument multiple<br>
constructors per module).<br>
<br>
Feel free to play with this, and then land this with tweaks, land it<br>
as-is, or don't land it, up to you :-)<br>
<span><font color="#888888"><br>
Nico<br>
</font></span><br></div></div>_______________________________________________<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>
<br></blockquote></div><br></div>
<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>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Alexey Samsonov, Mountain View, CA</div></div>
</font></span></div></div>
</blockquote></div><br></div>