You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support registering all runtime signal handlers with SA_ONSTACK #110368
Some languages and frameworks (like Go), require that all signals be registered with SA_ONSTACK because they create threads with very small stack sizes. .NET currently does not support this mode. All signal handling in the runtime would have to be audited and rewritten to support executing with SA_ONSTACK.
changed the title [-]Support registering all runtime signal handlers with SA_ONSTACK[/-][+]Support registering all runtime signal handlers with `SA_ONSTACK`[/+]on Dec 3, 2024
.NET actually uses SA_ONSTACK, but only for the SIGSEGV handler. For other hardware exception signals, a change to optionally use SA_ONSTACK everywhere should be trivial, basically sharing the existing mechanism for switching the stack the .NET handling code runs on back to the real stack. I am not sure about possible extra complexities for other signals like SIGINT, SIGQUIT, SIGABRT, SIGRTMIN, SIGUSR1 etc.
I hit the same class of issue (Go c-shared + Bun/JSC) and proposed a fix that avoids a full signal-handling rewrite: oven-sh/WebKit#235.
The key insight: handlers that break under SA_ONSTACK typically check their own stack pointer (e.g. for bounds validation). The fix is reading the interrupted thread's SP from ucontext->uc_mcontext.gregs[REG_RSP] instead of the handler's own frame pointer. That value is always the real execution stack regardless of where the handler itself runs.
This doesn't help with handlers that genuinely need more stack space than 16KB (complex unwinding, minidump collection). But for handlers that just make stack-position assumptions, it's a targeted change rather than a full audit.
@janvorli can correct me on this, but I think the tricky one is GC hijacking. That injects an interrupt and runs the GC hijacking. I think that's precisely the problem you mention -- there's no guarantee that the current handler is safe to execute in 16 KB.
And unfortunately I don't think there's a way around this case -- GC hijacking just seems like it's at risk of happening to any managed thread at any time, so you're rolling the dice by trying to avoid it.
So we need to either confirm that the hijacking is bounded, or do the same SIGSEGV dance to get back to the target thread.
Activity
dotnet-policy-service commentedon Dec 3, 2024
Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.
[-]Support registering all runtime signal handlers with SA_ONSTACK[/-][+]Support registering all runtime signal handlers with `SA_ONSTACK`[/+]janvorli commentedon Dec 3, 2024
.NET actually uses SA_ONSTACK, but only for the SIGSEGV handler. For other hardware exception signals, a change to optionally use SA_ONSTACK everywhere should be trivial, basically sharing the existing mechanism for switching the stack the .NET handling code runs on back to the real stack. I am not sure about possible extra complexities for other signals like SIGINT, SIGQUIT, SIGABRT, SIGRTMIN, SIGUSR1 etc.
gogakoreli commentedon May 22, 2026
I hit the same class of issue (Go c-shared + Bun/JSC) and proposed a fix that avoids a full signal-handling rewrite: oven-sh/WebKit#235.
The key insight: handlers that break under SA_ONSTACK typically check their own stack pointer (e.g. for bounds validation). The fix is reading the interrupted thread's SP from
ucontext->uc_mcontext.gregs[REG_RSP]instead of the handler's own frame pointer. That value is always the real execution stack regardless of where the handler itself runs.This doesn't help with handlers that genuinely need more stack space than 16KB (complex unwinding, minidump collection). But for handlers that just make stack-position assumptions, it's a targeted change rather than a full audit.
Related investigation connecting this to 9 other projects hitting the same root cause: https://gist.github.com/gogakoreli/46031843e2226a872341607612bd9dda
agocke commentedon May 23, 2026
@janvorli can correct me on this, but I think the tricky one is GC hijacking. That injects an interrupt and runs the GC hijacking. I think that's precisely the problem you mention -- there's no guarantee that the current handler is safe to execute in 16 KB.
And unfortunately I don't think there's a way around this case -- GC hijacking just seems like it's at risk of happening to any managed thread at any time, so you're rolling the dice by trying to avoid it.
So we need to either confirm that the hijacking is bounded, or do the same SIGSEGV dance to get back to the target thread.