Skip to content

Commit c4992bf

Browse files
kdavitalybuka
authored andcommitted
[NFC][sanitizer] Remove calls to __asan_get_current_fake_stack
Unnecessary with -fsanitize-address-use-after-return=never. for issue: google/sanitizers#1394 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D104154
1 parent af93157 commit c4992bf

File tree

4 files changed

+11
-28
lines changed

4 files changed

+11
-28
lines changed

compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ volatile char x;
3131
volatile int y = 1;
3232
volatile int z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13;
3333

34-
void recursive_func(char *p) {
34+
void recursive_func(uintptr_t parent_frame_address) {
3535
#if defined(SMALL_FRAME)
3636
char *buf = 0;
3737
#elif defined(SAVE_ALL_THE_REGISTERS)
@@ -69,14 +69,13 @@ void recursive_func(char *p) {
6969
#else
7070
char buf[BS];
7171
// Check that the stack grows in the righ direction, unless we use fake stack.
72-
if (p && !__asan_get_current_fake_stack())
73-
assert(p - buf >= BS);
72+
assert(parent_frame_address > (uintptr_t)__builtin_frame_address(0));
7473
buf[rand() % BS] = 1;
7574
buf[rand() % BS] = 2;
7675
x = buf[rand() % BS];
7776
#endif
7877
if (y)
79-
recursive_func(buf);
78+
recursive_func((uintptr_t)__builtin_frame_address(0));
8079
x = 1; // prevent tail call optimization
8180
// CHECK: {{stack-overflow on address 0x.* \(pc 0x.* bp 0x.* sp 0x.* T.*\)}}
8281
// If stack overflow happens during function prologue, stack trace may be
@@ -85,7 +84,7 @@ void recursive_func(char *p) {
8584
}
8685

8786
void *ThreadFn(void* unused) {
88-
recursive_func(0);
87+
recursive_func((uintptr_t)__builtin_frame_address(0));
8988
return 0;
9089
}
9190

@@ -110,7 +109,7 @@ int main(int argc, char **argv) {
110109
pthread_create(&t, 0, ThreadFn, 0);
111110
pthread_join(t, 0);
112111
#else
113-
recursive_func(0);
112+
recursive_func((uintptr_t)__builtin_frame_address(0));
114113
#endif
115114
return 0;
116115
}

compiler-rt/test/asan/TestCases/contiguous_container.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ void TestThrow() {
6565
assert(__asan_address_is_poisoned(x + 14));
6666
ThrowAndCatch();
6767
assert(!__asan_address_is_poisoned(x + 13));
68-
// FIXME: invert the assertion below once we fix
69-
// https://code.google.com/p/address-sanitizer/issues/detail?id=258
70-
// This assertion works only w/o UAR.
71-
if (!__asan_get_current_fake_stack())
72-
assert(!__asan_address_is_poisoned(x + 14));
68+
assert(!__asan_address_is_poisoned(x + 14));
7369
__sanitizer_annotate_contiguous_container(x, x + 32, x + 14, x + 32);
7470
assert(!__asan_address_is_poisoned(x + 13));
7571
assert(!__asan_address_is_poisoned(x + 14));

compiler-rt/test/asan/TestCases/longjmp.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx_asan -O %s -o %t && %run %t
1+
// RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t
22

33
#include <assert.h>
44
#include <setjmp.h>
@@ -17,9 +17,5 @@ int main() {
1717
longjmp(buf, 1);
1818
fprintf(stderr, "After: %p poisoned: %d\n", &x,
1919
__asan_address_is_poisoned(x + 32));
20-
// FIXME: Invert this assertion once we fix
21-
// https://code.google.com/p/address-sanitizer/issues/detail?id=258
22-
// This assertion works only w/o UAR.
23-
if (!__asan_get_current_fake_stack())
24-
assert(!__asan_address_is_poisoned(x + 32));
20+
assert(!__asan_address_is_poisoned(x + 32));
2521
}

compiler-rt/test/asan/TestCases/throw_catch.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx_asan -O %s -o %t && %run %t
1+
// RUN: %clangxx_asan -fsanitize-address-use-after-return=never -O %s -o %t && %run %t
22

33
#include <assert.h>
44
#include <stdio.h>
@@ -30,11 +30,7 @@ void TestThrow() {
3030
ThrowAndCatch();
3131
fprintf(stderr, "After: %p poisoned: %d\n", &x,
3232
__asan_address_is_poisoned(x + 32));
33-
// FIXME: Invert this assertion once we fix
34-
// https://code.google.com/p/address-sanitizer/issues/detail?id=258
35-
// This assertion works only w/o UAR.
36-
if (!__asan_get_current_fake_stack())
37-
assert(!__asan_address_is_poisoned(x + 32));
33+
assert(!__asan_address_is_poisoned(x + 32));
3834
}
3935

4036
__attribute__((noinline))
@@ -50,11 +46,7 @@ void TestThrowInline() {
5046
}
5147
fprintf(stderr, "After: %p poisoned: %d\n", &x,
5248
__asan_address_is_poisoned(x + 32));
53-
// FIXME: Invert this assertion once we fix
54-
// https://code.google.com/p/address-sanitizer/issues/detail?id=258
55-
// This assertion works only w/o UAR.
56-
if (!__asan_get_current_fake_stack())
57-
assert(!__asan_address_is_poisoned(x + 32));
49+
assert(!__asan_address_is_poisoned(x + 32));
5850
}
5951

6052
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)