Skip to content

Revert "[llvm][StackProtector] Add noreturn to __stack_chk_fail call" #144452

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
Jun 16, 2025

Conversation

PiJoules
Copy link
Contributor

Reverts #143976

Reverting since this broke a builder: https://lab.llvm.org/buildbot/#/builders/190/builds/21563

@PiJoules PiJoules merged commit d882670 into main Jun 16, 2025
6 of 8 checks passed
@PiJoules PiJoules deleted the revert-143976-stack-chk-fail-alias branch June 16, 2025 23:34
@llvmbot
Copy link
Member

llvmbot commented Jun 16, 2025

@llvm/pr-subscribers-llvm-transforms

Author: None (PiJoules)

Changes

Reverts llvm/llvm-project#143976

Reverting since this broke a builder: https://lab.llvm.org/buildbot/#/builders/190/builds/21563


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

3 Files Affected:

  • (modified) llvm/lib/CodeGen/StackProtector.cpp (+2-2)
  • (removed) llvm/test/Transforms/StackProtector/cross-dso-cfi-stack-chk-fail.ll (-33)
  • (removed) llvm/test/Transforms/StackProtector/stack-chk-fail-alias.ll (-21)
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index dda392d38b27a..5f866eea7d4e7 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -725,8 +725,8 @@ BasicBlock *CreateFailBB(Function *F, const Triple &Trip) {
     StackChkFail =
         M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context));
   }
-  CallInst *Call = B.CreateCall(StackChkFail, Args);
-  Call->addFnAttr(Attribute::NoReturn);
+  cast<Function>(StackChkFail.getCallee())->addFnAttr(Attribute::NoReturn);
+  B.CreateCall(StackChkFail, Args);
   B.CreateUnreachable();
   return FailBB;
 }
diff --git a/llvm/test/Transforms/StackProtector/cross-dso-cfi-stack-chk-fail.ll b/llvm/test/Transforms/StackProtector/cross-dso-cfi-stack-chk-fail.ll
deleted file mode 100644
index af03039813a2e..0000000000000
--- a/llvm/test/Transforms/StackProtector/cross-dso-cfi-stack-chk-fail.ll
+++ /dev/null
@@ -1,33 +0,0 @@
-;; This is a minimal reproducer that caused StackProtector to crash with a bad cast when
-;; CrossDSOCFI is used. This test just needs to not crash.
-; RUN: opt -mtriple=x86_64-pc-linux-gnu %s -passes=lowertypetests,cross-dso-cfi,stack-protector
-
-define hidden void @__stack_chk_fail() !type !1{
-  unreachable
-}
-
-define void @store_captures() sspstrong {
-entry:
-  %a = alloca i32, align 4
-  %j = alloca ptr, align 8
-  store ptr %a, ptr %j, align 8
-  ret void
-}
-
-define void @func(ptr %0) {
-entry:
-  %1 = call i1 @llvm.type.test(ptr %0, metadata !"typeid")
-  br i1 %1, label %cont, label %trap
-
-trap:                                             ; preds = %entry
-  call void @llvm.trap()
-  unreachable
-
-cont:                                             ; preds = %entry
-  call void %0()
-  ret void
-}
-
-!llvm.module.flags = !{!0}
-!0 = !{i32 4, !"Cross-DSO CFI", i32 1}
-!1 = !{i64 0, !"typeid"}
diff --git a/llvm/test/Transforms/StackProtector/stack-chk-fail-alias.ll b/llvm/test/Transforms/StackProtector/stack-chk-fail-alias.ll
deleted file mode 100644
index ab0a6e3f455e7..0000000000000
--- a/llvm/test/Transforms/StackProtector/stack-chk-fail-alias.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-;; __stack_chk_fail should have the noreturn attr even if it is an alias
-; RUN: opt -mtriple=x86_64-pc-linux-gnu %s -passes=stack-protector -S | FileCheck %s
-
-define hidden void @__stack_chk_fail_impl() {
-  unreachable
-}
-
-@__stack_chk_fail = hidden alias void (), ptr @__stack_chk_fail_impl
-
-; CHECK-LABEL: @store_captures(
-; CHECK:       CallStackCheckFailBlk:
-; CHECK-NEXT:      call void @__stack_chk_fail() [[ATTRS:#.*]]
-define void @store_captures() sspstrong {
-entry:
-  %a = alloca i32, align 4
-  %j = alloca ptr, align 8
-  store ptr %a, ptr %j, align 8
-  ret void
-}
-
-; CHECK: attributes [[ATTRS]] = { noreturn }

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 17, 2025

LLVM Buildbot has detected a new failure on builder lldb-arm-ubuntu running on linaro-lldb-arm-ubuntu while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/17575

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-shell :: ObjectFile/ELF/minidebuginfo-corrupt-xz.yaml (1438 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/elf-memory.test (1439 of 3265)
UNSUPPORTED: lldb-shell :: ObjectFile/ELF/minidebuginfo-no-lzma.yaml (1440 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/minidebuginfo-find-symbols.yaml (1441 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/netbsd-core-amd64.test (1442 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/netbsd-exec-8.99.30-amd64.yaml (1443 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/null-jmprel.yaml (1444 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/many-sections.s (1445 of 3265)
PASS: lldb-shell :: ObjectFile/ELF/section-addresses.yaml (1446 of 3265)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (1447 of 3265)
******************** TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch armv8l --build-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-server -p TestLldbGdbServer.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision d882670d498a29f4e02f357ef9fe07c43de034c8)
  clang revision d882670d498a29f4e02f357ef9fe07c43de034c8
  llvm revision d882670d498a29f4e02f357ef9fe07c43de034c8
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hc_then_Csignal_signals_correct_thread_launch_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hc_then_Csignal_signals_correct_thread_launch_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hg_switches_to_3_threads_launch_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_Hg_switches_to_3_threads_launch_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_P_and_p_thread_suffix_work_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_P_writes_all_gpr_registers_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_P_writes_all_gpr_registers_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_attach_commandline_continue_app_exits_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
lldb-server exiting...
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_attach_commandline_continue_app_exits_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_c_packet_works_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
lldb-server exiting...
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_c_packet_works_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_first_launch_stop_reply_thread_matches_first_qC_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_first_launch_stop_reply_thread_matches_first_qC_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_hardware_breakpoint_set_and_remove_work_debugserver (TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any category of interest for this run) 
lldb-server exiting...
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_hardware_breakpoint_set_and_remove_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants