mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
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:
Vendored
+14
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user