[compiler-rt] c4992bf - [NFC][sanitizer] Remove calls to __asan_get_current_fake_stack
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 15 18:52:34 PDT 2021
Author: Kevin Athey
Date: 2021-06-15T18:52:22-07:00
New Revision: c4992bf593a4fd2fd250c5ebe31aa9f26cc9ed40
URL: https://github.com/llvm/llvm-project/commit/c4992bf593a4fd2fd250c5ebe31aa9f26cc9ed40
DIFF: https://github.com/llvm/llvm-project/commit/c4992bf593a4fd2fd250c5ebe31aa9f26cc9ed40.diff
LOG: [NFC][sanitizer] Remove calls to __asan_get_current_fake_stack
Unnecessary with -fsanitize-address-use-after-return=never.
for issue: https://github.com/google/sanitizers/issues/1394
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D104154
Added:
Modified:
compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp
compiler-rt/test/asan/TestCases/contiguous_container.cpp
compiler-rt/test/asan/TestCases/longjmp.cpp
compiler-rt/test/asan/TestCases/throw_catch.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp b/compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp
index d6b062ed3fbf9..06057250f8759 100644
--- a/compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp
@@ -31,7 +31,7 @@ volatile char x;
volatile int y = 1;
volatile int z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13;
-void recursive_func(char *p) {
+void recursive_func(uintptr_t parent_frame_address) {
#if defined(SMALL_FRAME)
char *buf = 0;
#elif defined(SAVE_ALL_THE_REGISTERS)
@@ -69,14 +69,13 @@ void recursive_func(char *p) {
#else
char buf[BS];
// 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);
+ assert(parent_frame_address > (uintptr_t)__builtin_frame_address(0));
buf[rand() % BS] = 1;
buf[rand() % BS] = 2;
x = buf[rand() % BS];
#endif
if (y)
- recursive_func(buf);
+ recursive_func((uintptr_t)__builtin_frame_address(0));
x = 1; // prevent tail call optimization
// CHECK: {{stack-overflow on address 0x.* \(pc 0x.* bp 0x.* sp 0x.* T.*\)}}
// If stack overflow happens during function prologue, stack trace may be
@@ -85,7 +84,7 @@ void recursive_func(char *p) {
}
void *ThreadFn(void* unused) {
- recursive_func(0);
+ recursive_func((uintptr_t)__builtin_frame_address(0));
return 0;
}
@@ -110,7 +109,7 @@ int main(int argc, char **argv) {
pthread_create(&t, 0, ThreadFn, 0);
pthread_join(t, 0);
#else
- recursive_func(0);
+ recursive_func((uintptr_t)__builtin_frame_address(0));
#endif
return 0;
}
diff --git a/compiler-rt/test/asan/TestCases/contiguous_container.cpp b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
index 3f754562af31f..6ecade150fc18 100644
--- a/compiler-rt/test/asan/TestCases/contiguous_container.cpp
+++ b/compiler-rt/test/asan/TestCases/contiguous_container.cpp
@@ -65,11 +65,7 @@ void TestThrow() {
assert(__asan_address_is_poisoned(x + 14));
ThrowAndCatch();
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
- // This assertion works only w/o UAR.
- if (!__asan_get_current_fake_stack())
- assert(!__asan_address_is_poisoned(x + 14));
+ 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.cpp b/compiler-rt/test/asan/TestCases/longjmp.cpp
index 8e9f2ae195c71..66be9e32d0975 100644
--- a/compiler-rt/test/asan/TestCases/longjmp.cpp
+++ b/compiler-rt/test/asan/TestCases/longjmp.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan -O %s -o %t && %run %t
+// RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t
#include <assert.h>
#include <setjmp.h>
@@ -17,9 +17,5 @@ int main() {
longjmp(buf, 1);
fprintf(stderr, "After: %p poisoned: %d\n", &x,
__asan_address_is_poisoned(x + 32));
- // FIXME: Invert this assertion once we fix
- // https://code.google.com/p/address-sanitizer/issues/detail?id=258
- // This assertion works only w/o UAR.
- if (!__asan_get_current_fake_stack())
- assert(!__asan_address_is_poisoned(x + 32));
+ assert(!__asan_address_is_poisoned(x + 32));
}
diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cpp b/compiler-rt/test/asan/TestCases/throw_catch.cpp
index d7f00ea9e193c..2884e95f8a7e2 100644
--- a/compiler-rt/test/asan/TestCases/throw_catch.cpp
+++ b/compiler-rt/test/asan/TestCases/throw_catch.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan -O %s -o %t && %run %t
+// RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t
#include <assert.h>
#include <stdio.h>
@@ -30,11 +30,7 @@ void TestThrow() {
ThrowAndCatch();
fprintf(stderr, "After: %p poisoned: %d\n", &x,
__asan_address_is_poisoned(x + 32));
- // FIXME: Invert this assertion once we fix
- // https://code.google.com/p/address-sanitizer/issues/detail?id=258
- // This assertion works only w/o UAR.
- if (!__asan_get_current_fake_stack())
- assert(!__asan_address_is_poisoned(x + 32));
+ assert(!__asan_address_is_poisoned(x + 32));
}
__attribute__((noinline))
@@ -50,11 +46,7 @@ void TestThrowInline() {
}
fprintf(stderr, "After: %p poisoned: %d\n", &x,
__asan_address_is_poisoned(x + 32));
- // FIXME: Invert this assertion once we fix
- // https://code.google.com/p/address-sanitizer/issues/detail?id=258
- // This assertion works only w/o UAR.
- if (!__asan_get_current_fake_stack())
- assert(!__asan_address_is_poisoned(x + 32));
+ assert(!__asan_address_is_poisoned(x + 32));
}
int main(int argc, char **argv) {
More information about the llvm-commits
mailing list