<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><br><br><div class="gmail_quote">On Sun, Nov 11, 2012 at 10:17 AM, 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 style="font-family:arial,helvetica,sans-serif;font-size:10pt"><br><br><div class="gmail_quote"><div><div class="h5">
On Sun, Nov 11, 2012 at 10:10 PM, Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.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 Sun, Nov 11, 2012 at 7:32 PM, Dmitry N. Mikushin <<a href="mailto:maemarcus@gmail.com" target="_blank">maemarcus@gmail.com</a>> wrote:<br>


> In case of stack reuse there should be another llvm.livetime start/end<br>
> region, isn't it?<br>
<br>
</div>I was thinking about something like this:<br>
<br>
$ cat a.c<br>
#include <stdio.h><br>
<br>
void store_ptr(int *);<br>
int *load_ptr(void);<br>
int ret_int(void);<br>
void use_ptr(int *);<br>
extern int global;<br>
<br>
int main()<br>
{<br>
  {<br>
    int i[8];<br>
    store_ptr(i);<br>
  }<br>
  {<br>
    int j[8];<br>
    j[0] = ret_int();<br>
    use_ptr(j);<br>
    int *k = load_ptr();<br>
    *k = 42;<br>
    use_ptr(j);<br>
    printf("%d\n", global);<br>
  }<br>
}<br>
<br>
$ cat b.c<br>
static int *ptr;<br>
<br>
void store_ptr(int *p) { ptr = p; }<br>
int *load_ptr(void) { return ptr; }<br>
int ret_int() { return 7; }<br>
int global;<br>
void use_ptr(int *p) { global = *p; }<br>
<br>
Currently ASan does not catch an issue in this code, but with lifetime<br>
markers emitted by Clang, it should.<br>
<br>
Here 'i' and 'j' would occupy different addresses without stack reuse.<br>
 In this case, 'i' would be still allocated while 'j' is alive, but<br>
'i' would be poisoned.  With stack reuse, 'i' and 'j' will most likely<br>
occupy the same block of memory.<br></blockquote><div><br></div></div></div><div>I see. But we can explicitly turn off stack reuse optimization in ASan mode.</div></div></div></blockquote><div><br></div><div>Last time we discussed it, the resolution was that the stack reuse optimization</div>
<div>is going to work in codegen, i.e. after ASan. </div><div>Since ASan merges all Allocas into one, this will effectively disable the stack reuse optimization, </div><div>but nothing special needs to be done. </div><div>
If stack reuse is done before ASan, yes, we would need to disable it. </div><div><br></div><div>--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 style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div class="gmail_quote"><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/<br>
</div></div></blockquote></div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</font></span></div>
<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>
<br></blockquote></div><br></div>