[libc-commits] [libc] [libc] try fixing LlvmLibcStackChkFail.Smash again (PR #75967)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Tue Dec 19 13:03:20 PST 2023
https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/75967
Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23.
Forget lambdas and just use a static function.
>From e48f4e33e54aa5644c4af4b14655fc317db31d12 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 19 Dec 2023 13:01:30 -0800
Subject: [PATCH] [libc] try fixing LlvmLibcStackChkFail.Smash again
Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23.
Forget lambdas and just use a static function.
---
libc/test/src/compiler/stack_chk_guard_test.cpp | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index 6f1bd73b1faa3b..18bdc8f2a6e2ed 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -15,11 +15,13 @@ TEST(LlvmLibcStackChkFail, Death) {
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
}
+// Disable asan so that it doesn't immediately fail after the memset, but before
+// the stack canary is re-checked.
+[[gnu::no_sanitize_address]] static void smash_stack() {
+ int arr[20];
+ LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
+}
+
TEST(LlvmLibcStackChkFail, Smash) {
- EXPECT_DEATH(
- [] [[gnu::no_sanitize]] {
- int arr[20];
- LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
- },
- WITH_SIGNAL(SIGABRT));
+ EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
}
More information about the libc-commits
mailing list