Skip to content

Commit 7657030

Browse files
committed
Update test
1 parent 41c302e commit 7657030

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,30 @@
22

33
#include "defines.h"
44

5+
#include <cassert>
56
#include <sanitizer/asan_interface.h>
67

7-
volatile char *saved;
8+
volatile uintptr_t saved;
9+
10+
ATTRIBUTE_NOINLINE bool IsOnRealStack(uintptr_t caller_frame) {
11+
uintptr_t this_frame = reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
12+
return this_frame <= saved && saved <= caller_frame;
13+
}
814

915
ATTRIBUTE_NOINLINE bool IsOnStack() {
1016
volatile char temp = ' ';
11-
void *fake_stack = __asan_get_current_fake_stack();
12-
void *real = __asan_addr_is_in_fake_stack(
13-
fake_stack, const_cast<char *>(&temp), nullptr, nullptr);
14-
saved = &temp;
15-
return real == nullptr;
17+
saved = reinterpret_cast<uintptr_t>(&temp);
18+
return IsOnRealStack(reinterpret_cast<uintptr_t>(__builtin_frame_address(0)));
1619
}
1720

1821
int main(int argc, char *argv[]) {
22+
assert(!IsOnStack());
23+
1924
__asan_disable_fake_stack();
20-
if (!IsOnStack()) {
21-
return 1;
22-
}
25+
assert(IsOnStack());
26+
2327
__asan_enable_fake_stack();
24-
if (IsOnStack()) {
25-
return 2;
26-
}
28+
assert(!IsOnStack());
29+
2730
return 0;
2831
}

0 commit comments

Comments
 (0)