compiler, runtime: make runtime panics recoverable

Emit fault checkpoints around compiler-generated runtime assertions so
runtimePanicAt can unwind through the existing defer/recover machinery
instead of aborting. This lets panics from bounds checks, type checks,
and other compiler-inserted runtime checks be recovered by deferred
functions.

Mark functions that call recover as noinline. Inlining such a function
into a deferred closure can make recover observe the wrong call context
and report success when it should return nil.

Addresses tinygo-org/tinygo issues 2759 and 3510.
This commit is contained in:
Jake Bailey
2026-05-26 05:33:38 -07:00
committed by Ron Evans
parent ce888e1042
commit eed4afda63
9 changed files with 214 additions and 34 deletions
+14
View File
@@ -28,5 +28,19 @@ recovered: panic 2
defer panic
recovered from deferred call: deferred panic
# indirect recover
indirect recover returned: indirect panic
# runtime.Goexit
Goexit deferred function, recover is nil: true
# repanic
inner, repanicking
outer recovered: repanic value
# recover runtime errors
recovered: index
recovered: index from helper
recovered: slice
recovered: type assert
recovered: empty interface type assert