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 1212#include " src/string/memset.h"
1313#include " test/UnitTest/Test.h"
1414
15- namespace {
16-
1715TEST (LlvmLibcStackChkFail, Death) {
1816 EXPECT_DEATH ([] { __stack_chk_fail (); }, WITH_SIGNAL (SIGABRT));
1917}
2018
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
3122TEST (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));
3329}
34-
35- } // namespace
30+ #endif // LIBC_HAS_ADDRESS_SANITIZER
You can’t perform that action at this time.
0 commit comments