<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">Oh, that's too complex. <div><br></div><div><br></div><div>I'd prefer something like </div><div><br></div><div><div>===================================================================</div>
<div>--- asan_thread.cc      (revision 167542)</div><div>+++ asan_thread.cc      (working copy)</div><div>@@ -124,6 +124,8 @@</div><div>   } else {</div><div>     bottom = fake_stack().AddrIsInFakeStack(addr);</div><div>     CHECK(bottom);</div>
<div>+    *offset = addr - bottom;</div><div>+    return  (const char *)((uptr*)bottom)[1];</div><div>     is_fake_stack = true;</div><div>   }</div><div>   uptr aligned_addr = addr & ~(__WORDSIZE/8 - 1);  // align addr.</div>
</div><div><br></div><div><br></div><div>Can you please check if it works, revert this patch and apply the one above? </div><div><br></div><div><br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 5:40 AM, Alexander Potapenko <span dir="ltr"><<a href="mailto:glider@google.com" target="_blank">glider@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: glider<br>
Date: Thu Nov 15 07:40:44 2012<br>
New Revision: 168040<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=168040&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=168040&view=rev</a><br>
Log:<br>
[ASan] Poison the leftmost shadow byte with a special value so that we can find<br>
the beginning of the fake frame when reporting an use-after-return error.<br>
Fixes <a href="http://code.google.com/p/address-sanitizer/issues/detail?id=126" target="_blank">http://code.google.com/p/address-sanitizer/issues/detail?id=126</a><br>
<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/asan/asan_allocator.cc<br>
    compiler-rt/trunk/lib/asan/asan_internal.h<br>
    compiler-rt/trunk/lib/asan/asan_report.cc<br>
    compiler-rt/trunk/lib/asan/asan_thread.cc<br>
<br>
Modified: compiler-rt/trunk/lib/asan/asan_allocator.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=168040&r1=168039&r2=168040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.cc?rev=168040&r1=168039&r2=168040&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/asan_allocator.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/asan_allocator.cc Thu Nov 15 07:40:44 2012<br>
@@ -998,6 +998,10 @@<br>
   CHECK(fake_frame->descr != 0);<br>
   CHECK(fake_frame->size_minus_one == size - 1);<br>
   PoisonShadow(ptr, size, kAsanStackAfterReturnMagic);<br>
+  CHECK(size >= SHADOW_GRANULARITY);<br>
+  // Poison the leftmost shadow byte with a special value so that we can find<br>
+  // the beginning of the fake frame when reporting an error.<br>
+  PoisonShadow(ptr, SHADOW_GRANULARITY, kAsanStackAfterReturnLeftMagic);<br>
 }<br>
<br>
 }  // namespace __asan<br>
<br>
Modified: compiler-rt/trunk/lib/asan/asan_internal.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=168040&r1=168039&r2=168040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=168040&r1=168039&r2=168040&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)<br>
+++ compiler-rt/trunk/lib/asan/asan_internal.h Thu Nov 15 07:40:44 2012<br>
@@ -160,6 +160,7 @@<br>
 const int kAsanStackAfterReturnMagic = 0xf5;<br>
 const int kAsanInitializationOrderMagic = 0xf6;<br>
 const int kAsanUserPoisonedMemoryMagic = 0xf7;<br>
+const int kAsanStackAfterReturnLeftMagic = 0xf8;<br>
 const int kAsanGlobalRedzoneMagic = 0xf9;<br>
 const int kAsanInternalHeapMagic = 0xfe;<br>
<br>
<br>
Modified: compiler-rt/trunk/lib/asan/asan_report.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=168040&r1=168039&r2=168040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=168040&r1=168039&r2=168040&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/asan_report.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/asan_report.cc Thu Nov 15 07:40:44 2012<br>
@@ -450,6 +450,7 @@<br>
         bug_descr = "stack-buffer-overflow";<br>
         break;<br>
       case kAsanStackAfterReturnMagic:<br>
+      case kAsanStackAfterReturnLeftMagic:<br>
         bug_descr = "stack-use-after-return";<br>
         break;<br>
       case kAsanUserPoisonedMemoryMagic:<br>
<br>
Modified: compiler-rt/trunk/lib/asan/asan_thread.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=168040&r1=168039&r2=168040&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread.cc?rev=168040&r1=168039&r2=168040&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/asan_thread.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/asan_thread.cc Thu Nov 15 07:40:44 2012<br>
@@ -131,12 +131,14 @@<br>
   u8 *shadow_bottom = (u8*)MemToShadow(bottom);<br>
<br>
   while (shadow_ptr >= shadow_bottom &&<br>
-      *shadow_ptr != kAsanStackLeftRedzoneMagic) {<br>
+      *shadow_ptr != kAsanStackLeftRedzoneMagic &&<br>
+      *shadow_ptr != kAsanStackAfterReturnLeftMagic) {<br>
     shadow_ptr--;<br>
   }<br>
<br>
   while (shadow_ptr >= shadow_bottom &&<br>
-      *shadow_ptr == kAsanStackLeftRedzoneMagic) {<br>
+      (*shadow_ptr == kAsanStackLeftRedzoneMagic ||<br>
+       *shadow_ptr == kAsanStackAfterReturnLeftMagic)) {<br>
     shadow_ptr--;<br>
   }<br>
<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></div>