[libc-commits] [libc] y (PR #75988)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Dec 19 16:20:13 PST 2023


https://github.com/nickdesaulniers updated https://github.com/llvm/llvm-project/pull/75988

>From 10ce177fb196c6c8cdb679a7054ae943cfd902db Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 19 Dec 2023 16:12:03 -0800
Subject: [PATCH 1/2] [libc] try fixing LlvmLibcStackChkFail.Smash a third time

Build bots are failing in post submit. Unclear why but can't reproduce locally.
Disable this test for asan for now.
---
 .../src/compiler/stack_chk_guard_test.cpp     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index 18bdc8f2a6e2ed..427e20c2ac5046 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm-libc-macros/signal-macros.h"
+#include "src/__support/macros/sanitizer.h"
 #include "src/compiler/__stack_chk_fail.h"
 #include "src/string/memset.h"
 #include "test/UnitTest/Test.h"
@@ -15,13 +16,15 @@ 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);
-}
-
+// 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_HAVE_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));
 }
+#endif // LIBC_HAVE_ADDRESS_SANITIZER

>From ad2755cbda5724a952c288d9a8a1028905bbc430 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Tue, 19 Dec 2023 16:20:00 -0800
Subject: [PATCH 2/2] express cmake depencency properly

---
 libc/test/src/compiler/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libc/test/src/compiler/CMakeLists.txt b/libc/test/src/compiler/CMakeLists.txt
index b8d682c1c519a5..65a9acceb6f7f1 100644
--- a/libc/test/src/compiler/CMakeLists.txt
+++ b/libc/test/src/compiler/CMakeLists.txt
@@ -7,6 +7,7 @@ add_libc_unittest(
   SRCS
     stack_chk_guard_test.cpp
   DEPENDS
+    libc.src.__support.macros.sanitizer
     libc.src.compiler.__stack_chk_fail
     libc.src.string.memset
   COMPILE_OPTIONS



More information about the libc-commits mailing list