mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 20:43:40 +00:00
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:
@@ -28,15 +28,15 @@ func exit(goexit bool) {
|
||||
if t == mainTask {
|
||||
if goexit {
|
||||
if remaining == 0 {
|
||||
runtimePanic("all goroutines are asleep - deadlock!")
|
||||
runtimeFatal("all goroutines are asleep - deadlock!")
|
||||
}
|
||||
atomic.StoreUint32(&mainExitedByGoexit, 1)
|
||||
}
|
||||
} else if atomic.LoadUint32(&mainExitedByGoexit) != 0 && remaining == 0 {
|
||||
runtimePanic("all goroutines are asleep - deadlock!")
|
||||
runtimeFatal("all goroutines are asleep - deadlock!")
|
||||
}
|
||||
|
||||
// TODO: explicitly free the stack after switching back to the scheduler.
|
||||
Pause()
|
||||
runtimePanic("unreachable")
|
||||
runtimeFatal("unreachable")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user