Skip to content

Commit 2276491

Browse files
[libc] try fixing LlvmLibcStackChkFail.Smash a third time (#75988)
Build bots are failing in post submit. Unclear why but can't reproduce locally. Disable this test for asan for now.
1 parent 71a9292 commit 2276491

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

libc/test/src/compiler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_libc_unittest(
77
SRCS
88
stack_chk_guard_test.cpp
99
DEPENDS
10+
libc.src.__support.macros.sanitizer
1011
libc.src.compiler.__stack_chk_fail
1112
libc.src.string.memset
1213
COMPILE_OPTIONS

libc/test/src/compiler/stack_chk_guard_test.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm-libc-macros/signal-macros.h"
10+
#include "src/__support/macros/sanitizer.h"
1011
#include "src/compiler/__stack_chk_fail.h"
1112
#include "src/string/memset.h"
1213
#include "test/UnitTest/Test.h"
@@ -15,13 +16,15 @@ TEST(LlvmLibcStackChkFail, Death) {
1516
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
1617
}
1718

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-
19+
// Disable the test when asan is enabled so that it doesn't immediately fail
20+
// after the memset, but before the stack canary is re-checked.
21+
#ifndef LIBC_HAVE_ADDRESS_SANITIZER
2522
TEST(LlvmLibcStackChkFail, Smash) {
26-
EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
23+
EXPECT_DEATH(
24+
[] {
25+
int arr[20];
26+
LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
27+
},
28+
WITH_SIGNAL(SIGABRT));
2729
}
30+
#endif // LIBC_HAVE_ADDRESS_SANITIZER

0 commit comments

Comments
 (0)