Skip to content

[libc] try fixing LlvmLibcStackChkFail.Smash again #75967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

nickdesaulniers
Copy link
Member

Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23.
Forget lambdas and just use a static function.

Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23.
Forget lambdas and just use a static function.
@llvmbot
Copy link
Member

llvmbot commented Dec 19, 2023

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

Looks like adding attributes to lambdas wasn't added to ISO C++ until C++23.
Forget lambdas and just use a static function.


Full diff: https://github.com/llvm/llvm-project/pull/75967.diff

1 Files Affected:

  • (modified) libc/test/src/compiler/stack_chk_guard_test.cpp (+8-6)
diff --git a/libc/test/src/compiler/stack_chk_guard_test.cpp b/libc/test/src/compiler/stack_chk_guard_test.cpp
index 6f1bd73b1faa3b..18bdc8f2a6e2ed 100644
--- a/libc/test/src/compiler/stack_chk_guard_test.cpp
+++ b/libc/test/src/compiler/stack_chk_guard_test.cpp
@@ -15,11 +15,13 @@ 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);
+}
+
 TEST(LlvmLibcStackChkFail, Smash) {
-  EXPECT_DEATH(
-      [] [[gnu::no_sanitize]] {
-        int arr[20];
-        LIBC_NAMESPACE::memset(arr, 0xAA, 2001);
-      },
-      WITH_SIGNAL(SIGABRT));
+  EXPECT_DEATH(smash_stack, WITH_SIGNAL(SIGABRT));
 }

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nickdesaulniers
Copy link
Member Author

Might need to follow up and disable msan, too, but I will wait until our internal fuzzers spot that or not.

@nickdesaulniers nickdesaulniers merged commit b3d024c into llvm:main Dec 19, 2023
@nickdesaulniers nickdesaulniers deleted the libc_c23 branch December 19, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants