Skip to content

Commit b3d024c

Browse files
[libc] try fixing LlvmLibcStackChkFail.Smash again (llvm#75967)
Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23. Forget lambdas and just use a static function.
1 parent 535520c commit b3d024c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libc/test/src/compiler/stack_chk_guard_test.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ TEST(LlvmLibcStackChkFail, Death) {
1515
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
1616
}
1717

18+
// Disable asan so that it doesn't immediately fail after the memset, but before
19+
// the stack canary is re-checked.
20+
[[gnu::no_sanitize_address]] static void smash_stack() {
21+
int arr[20];
22+
LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
23+
}
24+
1825
TEST(LlvmLibcStackChkFail, Smash) {
19-
EXPECT_DEATH(
20-
[] [[gnu::no_sanitize]] {
21-
int arr[20];
22-
LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
23-
},
24-
WITH_SIGNAL(SIGABRT));
26+
EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
2527
}

0 commit comments

Comments
 (0)