[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
This commit is contained in:
Kevin Athey 2021-06-15 18:26:31 -07:00 committed by Vitaly Buka
parent af93157625
commit c4992bf593
4 changed files with 11 additions and 28 deletions

View File

@ -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;
}

View File

@ -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));

View File

@ -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));
}

View File

@ -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) {