[asan] fix four asan tests to run in use-after-return mode
authorKostya Serebryany <kcc@google.com>
Wed, 3 Dec 2014 00:08:41 +0000 (00:08 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 3 Dec 2014 00:08:41 +0000 (00:08 +0000)
llvm-svn: 223181

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

index 8d8c8d0..0f3a7db 100644 (file)
@@ -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));
index 5472330..8e9f2ae 100644 (file)
@@ -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));
 }
index 9d7c72c..7542d56 100644 (file)
@@ -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;
index 7e0d76d..bce4819 100644 (file)
@@ -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) {