Repository navigation
Restore SIGTRAP before abort() so the process can exit as PID 1 - #137998
Merged
Merged
Conversation
When PROCAbort calls abort() and SIGABRT does not terminate the process (e.g. the process is PID 1 in a container, where the kernel drops SIGABRT with the default disposition), glibc < 2.41 falls back to its ABORT_INSTRUCTION. On arm64 that is `brk`, which raises SIGTRAP. The runtime's sigtrap_handler was still installed, returned to the same brk, and the process spun forever at 100% CPU instead of exiting. Restore the original SIGTRAP disposition along with SIGABRT in SEHCleanupSignals so the kernel terminates the process. Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
jkotas
reviewed
Nov 20, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The process-wide fatal-signal changes affect a path with a prior concurrent-crash regression, requiring maintainer confirmation of reported older-glibc ARM64/PID-1 validation and concurrency coverage that could not be independently exercised.
No open issues 🎉
What changed in this PR
This PR addresses the PID 1 shutdown hang in #118049 by restoring SIGTRAP before CoreCLR calls abort(), allowing its fallback trap to terminate the process on affected Linux systems.
Changes:
- Restore
SIGTRAPalongsideSIGABRTon platforms without Mach exceptions, sharing the restoration with child-process cleanup. - Keep other hardware exception handlers installed during abort to preserve concurrent-crash handling.
- Update the
PROCAbortcomment to describe the selective signal restoration accurately.
| File | Description |
|---|---|
src/coreclr/pal/src/thread/process.cpp |
Corrects the comment describing signal cleanup before abort(). |
src/coreclr/pal/src/exception/signal.cpp |
Moves SIGTRAP restoration into shared cleanup and explains the PID 1 fallback-trap behavior. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
This was referenced Nov 20, 2026
jkotas
approved these changes
Nov 23, 2026
Member
|
/ba-g dead letter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #118049
Problem
A .NET process running as PID 1 in a container, without an init process such as
docker run --init, can hang at 100% CPU after an unhandled exception orEnvironment.FailFast, instead of exiting. This affects Linux architectures where glibc'sabort()fallback instruction raisesSIGTRAP(arm64, loongarch64, riscv64) with glibc older than 2.41 (for example Ubuntu 22.04/24.04 and Debian 12) on .NET 9, 10 and 11. It happens with and withoutDOTNET_DbgEnableMiniDump.Cause
In .NET 9, #105578 changed
SEHCleanupSignals(false), whichPROCAbortcalls just beforeabort(), so that it restores onlySIGABRT. Before that, all handlers were restored, which is how #66707 was fixed in .NET 8.The kernel ignores a
SIGABRTthat PID 1 sends itself when the handler is the default. glibc'sabort()then falls back to a trap instruction (brk #1000on arm64). The trap raisesSIGTRAP. The runtime'sSIGTRAPhandler is still installed, and it returns to the samebrkinstruction, so the process spins forever.Why only older glibc: glibc 2.41 rewrote
abort()(BZ 26275) and now blocks all signals before it runs the trap instruction. When a trap fires while its signal is blocked, the kernel can't call our handler. Instead it forces the default action, which terminates the process even as PID 1, with exit code 133. Older glibc leaves signals unblocked, so our handler runs and the loop starts. Newer distros (for example Ubuntu 26.04, which the .NET 11 container images use) mask the runtime bug; they don't fix it.On x64 the fallback (
hlt) raisesSIGSEGV, which already exits after #110379. On arm32, ppc64le and s390x it raisesSIGILL, whose handler likewise restores the default and re-runs the instruction.riscv64 (
ebreak) and loongarch64 (break 0) also fall back to a SIGTRAP-raising trap, so they're expected to hit the same hang. This change covers them too. musl (Alpine) isn't affected, because itsabort()blocks all signals before the trap.Fix
Restore
SIGTRAPtogether withSIGABRTin the abort path ofSEHCleanupSignals(Linux/FreeBSD only; macOS uses Mach exceptions). The other hardware exception handlers stay installed, so #46175 (fixed by #105578) is not reintroduced. TheSIGTRAPrestore in the child-process path is now covered by the shared block.Validation
I built linux-arm64
libcoreclr.sofrom v11.0.0, with and without this change. Each build ran as PID 1 in an Ubuntu 24.04 (glibc 2.39) container, with an app that throws an unhandled exception:DOTNET_DbgEnableMiniDump=1--initThere is no automated test: PID 1 signal behavior needs a dedicated PID namespace (container), which our test infrastructure doesn't provide.
Note
This PR description was drafted with GitHub Copilot.