Skip to content

Commit 66ce716

Browse files
authored
Revert "[libc] Make LlvmLibcStackChkFail.Smash test compatible with asan, hwasan" (#125785)
Reverts #125763 This causes failures in asan. More thought is needed.
1 parent e8d437f commit 66ce716

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

libc/test/src/compiler/stack_chk_guard_test.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,19 @@
1212
#include "src/string/memset.h"
1313
#include "test/UnitTest/Test.h"
1414

15-
namespace {
16-
1715
TEST(LlvmLibcStackChkFail, Death) {
1816
EXPECT_DEATH([] { __stack_chk_fail(); }, WITH_SIGNAL(SIGABRT));
1917
}
2018

21-
// Disable sanitizers such as asan and hwasan that would catch the buffer
22-
// overrun before it clobbered the stack canary word. Function attributes
23-
// can't be applied to lambdas before C++23, so this has to be separate. When
24-
// https://github.com/llvm/llvm-project/issues/125760 is fixed, this can use
25-
// the modern spelling [[gnu::no_sanitize(...)]] without conditionalization.
26-
__attribute__((no_sanitize("all"))) void smash_stack() {
27-
int arr[20];
28-
LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
29-
}
30-
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_HAS_ADDRESS_SANITIZER
3122
TEST(LlvmLibcStackChkFail, Smash) {
32-
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));
3329
}
34-
35-
} // namespace
30+
#endif // LIBC_HAS_ADDRESS_SANITIZER

0 commit comments

Comments
 (0)