[libc-commits] [libc] Revert "[libc] Make LlvmLibcStackChkFail.Smash test compatible with asan, hwasan" (PR #125785)
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Tue Feb 4 16:06:18 PST 2025
https://github.com/frobtech created https://github.com/llvm/llvm-project/pull/125785
Reverts llvm/llvm-project#125763
This causes failures in asan. More thought is needed.
>From 559687352284d56b1290327260111f8a6534801b Mon Sep 17 00:00:00 2001
From: Roland McGrath <roland at hack.frob.com>
Date: Tue, 4 Feb 2025 16:05:47 -0800
Subject: [PATCH] =?UTF-8?q?Revert=20"[libc]=20Make=20LlvmLibcStackChkFail.?=
=?UTF-8?q?Smash=20test=20compatible=20with=20asan,=20hwa=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit 1e7624ca4f3c9df14242b532eeb9497c67bc4074.
---
.../src/compiler/stack_chk_guard_test.cpp | 25 ++++++++-----------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index d1869a2af412e4..4ec8398c9fc95d 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -12,24 +12,19 @@
#include "src/string/memset.h"
#include "test/UnitTest/Test.h"
-namespace {
-
TEST(LlvmLibcStackChkFail, Death) {
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
}
-// Disable sanitizers such as asan and hwasan that would catch the buffer
-// overrun before it clobbered the stack canary word. Function attributes
-// can't be applied to lambdas before C++23, so this has to be separate. When
-// https://github.com/llvm/llvm-project/issues/125760 is fixed, this can use
-// the modern spelling [[gnu::no_sanitize(...)]] without conditionalization.
-__attribute__((no_sanitize("all"))) void smash_stack() {
- int arr[20];
- LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
-}
-
+// Disable the test when asan is enabled so that it doesn't immediately fail
+// after the memset, but before the stack canary is re-checked.
+#ifndef LIBC_HAS_ADDRESS_SANITIZER
TEST(LlvmLibcStackChkFail, Smash) {
- EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
+ EXPECT_DEATH(
+ [] {
+ int arr[20];
+ LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
+ },
+ WITH_SIGNAL(SIGABRT));
}
-
-} // namespace
+#endif // LIBC_HAS_ADDRESS_SANITIZER
More information about the libc-commits
mailing list