[libc-commits] [libc] [libc] Make LlvmLibcStackChkFail.Smash test compatible with asan, hwasan (PR #125763)
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Tue Feb 4 13:36:47 PST 2025
================
@@ -12,19 +12,30 @@
#include "src/string/memset.h"
#include "test/UnitTest/Test.h"
+namespace {
+
TEST(LlvmLibcStackChkFail, Death) {
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
}
-// 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
+// When https://github.com/llvm/llvm-project/issues/125760 is fixed,
+// this can use the `gnu::` spelling unconditionally.
+#ifdef __clang__
+#define SANITIZER_ATTR_NS clang
+#else
+#define SANITIZER_ATTR_NS gnu
+#endif
+
+// 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.
+[[SANITIZER_ATTR_NS::no_sanitize("all")]] void smash_stack() {
----------------
frobtech wrote:
Done.
https://github.com/llvm/llvm-project/pull/125763
More information about the libc-commits
mailing list