mirror of
https://github.com/golang/go
synced 2024-11-17 05:14:56 -07:00
cmd/compile: print "internal compiler error" message for all compiler panics
Change hidePanic (now renamed handlePanic) to print out the "internal compiler error" message for all panics and runtime exceptions, similar to what we already do for the SSA backend in ssa.Compile(). Previously, hidePanic would not catch panics/exceptions unless it wanted to completely hide the panic because there had already been some compiler errors. Tested by manually inserting a seg fault in the compiler, and verifying that the seg fault is cause and "internal compiler error" message (with stack trace) is displayed proeprly. Updates #50423 Change-Id: Ibe846012e147fcdcc63ac147aae4bdfc47bf5a58 Reviewed-on: https://go-review.googlesource.com/c/go/+/376057 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
1cc3c73580
commit
1abe9c1c73
@ -35,18 +35,18 @@ import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
func hidePanic() {
|
||||
if base.Debug.Panic == 0 && base.Errors() > 0 {
|
||||
// If we've already complained about things
|
||||
// in the program, don't bother complaining
|
||||
// about a panic too; let the user clean up
|
||||
// the code and try again.
|
||||
if err := recover(); err != nil {
|
||||
if err == "-h" {
|
||||
panic(err)
|
||||
}
|
||||
base.ErrorExit()
|
||||
// handlePanic ensures that we print out an "internal compiler error" for any panic
|
||||
// or runtime exception during front-end compiler processing (unless there have
|
||||
// already been some compiler errors). It may also be invoked from the explicit panic in
|
||||
// hcrash(), in which case, we pass the panic on through.
|
||||
func handlePanic() {
|
||||
if err := recover(); err != nil {
|
||||
if err == "-h" {
|
||||
// Force real panic now with -h option (hcrash) - the error
|
||||
// information will have already been printed.
|
||||
panic(err)
|
||||
}
|
||||
base.Fatalf("panic: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ func hidePanic() {
|
||||
func Main(archInit func(*ssagen.ArchInfo)) {
|
||||
base.Timer.Start("fe", "init")
|
||||
|
||||
defer hidePanic()
|
||||
defer handlePanic()
|
||||
|
||||
archInit(&ssagen.Arch)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user