runtime: make fatal failures unrecoverable

Match the Go runtime by terminating for deadlocks, stack overflows,
runtime and GC invariants, invalid lock operations, and platform
initialization failures instead of routing them through panic/recover.

Keep language-level runtime errors and unsupported user operations
recoverable. Add crash coverage that verifies fatal errors bypass deferred
recover calls.
This commit is contained in:
Jake Bailey
2026-07-24 10:49:50 -07:00
committed by Ron Evans
parent 9105cce340
commit 16fc1ea2bb
41 changed files with 144 additions and 101 deletions
+2 -5
View File
@@ -11,9 +11,6 @@ import (
// otherwise Go wouldn't allow the cast to a smaller integer size.
const stackCanary = uintptr(uint64(0x670c1333b83bf575) & uint64(^uintptr(0)))
//go:linkname runtimePanic runtime.runtimePanic
func runtimePanic(str string)
// state is a structure which holds a reference to the state of the task.
// When the task is suspended, the stack pointers are saved here.
type state struct {
@@ -95,7 +92,7 @@ func Current() *Task {
// This function may only be called when running on a goroutine stack, not when running on the system stack.
func Pause() {
if *currentTask.state.canaryPtr != stackCanary {
runtimePanic("stack overflow")
runtimeFatal("stack overflow")
}
currentTask.state.unwind()
@@ -124,7 +121,7 @@ func (t *Task) Resume() {
currentTask = prevTask
t.gcData.swap()
if uintptr(t.state.asyncifysp) > uintptr(t.state.csp) {
runtimePanic("stack overflow")
runtimeFatal("stack overflow")
}
}