From c93c84e882d763584ce4c8d911db50f2a0eacb9b Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 3 Dec 2014 00:08:41 +0000 Subject: [PATCH] [asan] fix four asan tests to run in use-after-return mode llvm-svn: 223181 --- compiler-rt/test/asan/TestCases/contiguous_container.cc | 4 +++- compiler-rt/test/asan/TestCases/longjmp.cc | 4 +++- compiler-rt/test/asan/TestCases/stack-overflow.cc | 4 +++- compiler-rt/test/asan/TestCases/throw_catch.cc | 8 ++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/compiler-rt/test/asan/TestCases/contiguous_container.cc b/compiler-rt/test/asan/TestCases/contiguous_container.cc index 8d8c8d0..0f3a7db 100644 --- a/compiler-rt/test/asan/TestCases/contiguous_container.cc +++ b/compiler-rt/test/asan/TestCases/contiguous_container.cc @@ -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)); diff --git a/compiler-rt/test/asan/TestCases/longjmp.cc b/compiler-rt/test/asan/TestCases/longjmp.cc index 5472330..8e9f2ae 100644 --- a/compiler-rt/test/asan/TestCases/longjmp.cc +++ b/compiler-rt/test/asan/TestCases/longjmp.cc @@ -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)); } diff --git a/compiler-rt/test/asan/TestCases/stack-overflow.cc b/compiler-rt/test/asan/TestCases/stack-overflow.cc index 9d7c72c..7542d56 100644 --- a/compiler-rt/test/asan/TestCases/stack-overflow.cc +++ b/compiler-rt/test/asan/TestCases/stack-overflow.cc @@ -22,6 +22,7 @@ #include #include #include +#include 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; diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cc b/compiler-rt/test/asan/TestCases/throw_catch.cc index 7e0d76d..bce4819 100644 --- a/compiler-rt/test/asan/TestCases/throw_catch.cc +++ b/compiler-rt/test/asan/TestCases/throw_catch.cc @@ -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) { -- 2.7.4