[compiler-rt] r223181 - [asan] fix four asan tests to run in use-after-return mode

Kostya Serebryany kcc at google.com
Tue Dec 2 16:08:41 PST 2014


Author: kcc
Date: Tue Dec  2 18:08:41 2014
New Revision: 223181

URL: http://llvm.org/viewvc/llvm-project?rev=223181&view=rev
Log:
[asan] fix four asan tests to run in use-after-return mode 

Modified:
    compiler-rt/trunk/test/asan/TestCases/contiguous_container.cc
    compiler-rt/trunk/test/asan/TestCases/longjmp.cc
    compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc
    compiler-rt/trunk/test/asan/TestCases/throw_catch.cc

Modified: compiler-rt/trunk/test/asan/TestCases/contiguous_container.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/contiguous_container.cc?rev=223181&r1=223180&r2=223181&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/contiguous_container.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/contiguous_container.cc Tue Dec  2 18:08:41 2014
@@ -59,7 +59,9 @@ void TestThrow() {
   assert(!__asan_address_is_poisoned(x + 13));
   // FIXME: invert the assertion below once we fix
   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
-  assert(!__asan_address_is_poisoned(x + 14));
+  // This assertion works only w/o UAR.
+  if (!__asan_get_current_fake_stack())
+    assert(!__asan_address_is_poisoned(x + 14));
   __sanitizer_annotate_contiguous_container(x, x + 32, x + 14, x + 32);
   assert(!__asan_address_is_poisoned(x + 13));
   assert(!__asan_address_is_poisoned(x + 14));

Modified: compiler-rt/trunk/test/asan/TestCases/longjmp.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/longjmp.cc?rev=223181&r1=223180&r2=223181&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/longjmp.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/longjmp.cc Tue Dec  2 18:08:41 2014
@@ -19,5 +19,7 @@ int main() {
           __asan_address_is_poisoned(x + 32));
   // FIXME: Invert this assertion once we fix
   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
-  assert(!__asan_address_is_poisoned(x + 32));
+  // This assertion works only w/o UAR.
+  if (!__asan_get_current_fake_stack())
+    assert(!__asan_address_is_poisoned(x + 32));
 }

Modified: compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc?rev=223181&r1=223180&r2=223181&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/stack-overflow.cc Tue Dec  2 18:08:41 2014
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <sanitizer/asan_interface.h>
 
 const int BS = 1024;
 volatile char x;
@@ -65,7 +66,8 @@ void recursive_func(char *p) {
   z13 = t13;
 #else
   char buf[BS];
-  if (p)
+  // Check that the stack grows in the righ direction, unless we use fake stack.
+  if (p && !__asan_get_current_fake_stack())
     assert(p - buf >= BS);
   buf[rand() % BS] = 1;
   buf[rand() % BS] = 2;

Modified: compiler-rt/trunk/test/asan/TestCases/throw_catch.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/throw_catch.cc?rev=223181&r1=223180&r2=223181&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/throw_catch.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/throw_catch.cc Tue Dec  2 18:08:41 2014
@@ -34,7 +34,9 @@ void TestThrow() {
           __asan_address_is_poisoned(x + 32));
   // FIXME: Invert this assertion once we fix
   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
-  assert(!__asan_address_is_poisoned(x + 32));
+  // This assertion works only w/o UAR.
+  if (!__asan_get_current_fake_stack())
+    assert(!__asan_address_is_poisoned(x + 32));
 }
 
 void TestThrowInline() {
@@ -51,7 +53,9 @@ void TestThrowInline() {
           __asan_address_is_poisoned(x + 32));
   // FIXME: Invert this assertion once we fix
   // https://code.google.com/p/address-sanitizer/issues/detail?id=258
-  assert(!__asan_address_is_poisoned(x + 32));
+  // This assertion works only w/o UAR.
+  if (!__asan_get_current_fake_stack())
+    assert(!__asan_address_is_poisoned(x + 32));
 }
 
 int main(int argc, char **argv) {





More information about the llvm-commits mailing list