Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: throw instead of panic in runtime #25201
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.
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.
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 <email@example.com>