New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: throw instead of panic in runtime #25201
Comments
So the only way to get a panicindex in the runtime is with an explicit panic call? |
@josharian sorry if am preaching to the choir but won't this technically violate the spec https://golang.org/ref/spec#Run_time_panics which requires panics with runtime.Error for slice access issues? |
I don't think so. That's for observable panics. These "panics" are failures of the language implementation, and this change just makes sure that those take down the process rather than letting it continue in a broken state. |
Change https://golang.org/cl/111257 mentions this issue: |
Not going to do this. See the discussion in the CL. |
Change https://golang.org/cl/121515 mentions this issue: |
If the runtime code panics due to a bad index or slice expression, then throw instead of panicing. This will skip calls to recover and dump the entire runtime stack trace. The runtime should never panic due to an out of bounds index, and this will help with debugging if it does. For #24991 Updates #25201 Change-Id: I85a9feded8f0de914ee1558425931853223c0514 Reviewed-on: https://go-review.googlesource.com/121515 Reviewed-by: Austin Clements <austin@google.com>
For discussion; I don't know whether this is a good idea.
The runtime uses slices. Though the runtime contributors Never Make Mistakes, slice accesses can panic. Most such panics are very bad news. However, they might be caught by another package's recover. That's why we have throw.
We might want to have the compiler automatically insert throwindex instead of panicindex, throwslice instead of panicslice, etc. when compiling the runtime.
cc @aclements @randall77
The text was updated successfully, but these errors were encountered: