File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change 12
12
#include " src/string/memset.h"
13
13
#include " test/UnitTest/Test.h"
14
14
15
- namespace {
16
-
17
15
TEST (LlvmLibcStackChkFail, Death) {
18
16
EXPECT_DEATH ([] { __stack_chk_fail (); }, WITH_SIGNAL (SIGABRT));
19
17
}
20
18
21
- // Disable sanitizers such as asan and hwasan that would catch the buffer
22
- // overrun before it clobbered the stack canary word. Function attributes
23
- // can't be applied to lambdas before C++23, so this has to be separate. When
24
- // https://github.com/llvm/llvm-project/issues/125760 is fixed, this can use
25
- // the modern spelling [[gnu::no_sanitize(...)]] without conditionalization.
26
- __attribute__ ((no_sanitize(" all" ))) void smash_stack () {
27
- int arr[20 ];
28
- LIBC_NAMESPACE::memset (arr, 0xAA , 2001 );
29
- }
30
-
19
+ // Disable the test when asan is enabled so that it doesn't immediately fail
20
+ // after the memset, but before the stack canary is re-checked.
21
+ #ifndef LIBC_HAS_ADDRESS_SANITIZER
31
22
TEST (LlvmLibcStackChkFail, Smash) {
32
- EXPECT_DEATH (smash_stack, WITH_SIGNAL (SIGABRT));
23
+ EXPECT_DEATH (
24
+ [] {
25
+ int arr[20 ];
26
+ LIBC_NAMESPACE::memset (arr, 0xAA , 2001 );
27
+ },
28
+ WITH_SIGNAL (SIGABRT));
33
29
}
34
-
35
- } // namespace
30
+ #endif // LIBC_HAS_ADDRESS_SANITIZER
You can’t perform that action at this time.
0 commit comments