https://github.com/rjmansfield created https://github.com/llvm/llvm-project/pull/183560
When cc1 runs out-of-process and crashes, sys::ExecuteAndWait returns -2 for signal-killed children. The resignaling block added in 15488a7f78ce only handled CommandRes > 128, so the driver would exit normally with code 1 instead of dying by signal. >From 0e0955201989268f90f7e6a72bdd8aecb7734506 Mon Sep 17 00:00:00 2001 From: Ryan Mansfield <[email protected]> Date: Thu, 26 Feb 2026 11:04:39 -0500 Subject: [PATCH] [clang] Fix driver resignaling when cc1 runs out-of-process When cc1 runs out-of-process and crashes, sys::ExecuteAndWait returns -2 for signal-killed children. The resignaling block added in 15488a7f78ce only handled CommandRes > 128, so the driver would exit normally with code 1 instead of dying by signal. --- clang/test/Driver/crash-report-no-integrated-cc1.c | 8 ++++++++ clang/tools/driver/driver.cpp | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 clang/test/Driver/crash-report-no-integrated-cc1.c diff --git a/clang/test/Driver/crash-report-no-integrated-cc1.c b/clang/test/Driver/crash-report-no-integrated-cc1.c new file mode 100644 index 0000000000000..703db50da7c06 --- /dev/null +++ b/clang/test/Driver/crash-report-no-integrated-cc1.c @@ -0,0 +1,8 @@ +// Test that the clang driver exits via signal when cc1 runs out-of-process +// (-fno-integrated-cc1) and crashes. +// +// RUN: not %crash_opt %clang %s -fsyntax-only -fno-integrated-cc1 2>&1 +// +// REQUIRES: crash-recovery + +#pragma clang __debug parser_crash diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index fa110e998f142..1fffa579a9c8c 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -486,6 +486,13 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) { llvm::sys::unregisterHandlers(); raise(CommandRes - 128); } + // When cc1 runs out-of-process (CLANG_SPAWN_CC1), ExecuteAndWait returns -2 + // if the child was killed by a signal. The signal number is not preserved, + // so resignal with SIGABRT to ensure the driver exits via signal. + if (CommandRes == -2) { + llvm::sys::unregisterHandlers(); + raise(SIGABRT); + } #endif // If we have multiple failing commands, we return the result of the first _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
