From 38d1ec8c9d09c680065404fe77168fe992e09e82 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 29 Oct 2020 13:57:12 -0400 Subject: [PATCH] cmd/internal/obj: use panic instead of log.Fatalf for two messages These messages can happen if there are duplicate body-less function declarations. Using panic gives the panic handler a chance to handle the panic by printing the queued error messages instead of an internal error. And if there are no queued error messages, using panic pinpoints the stack trace leading to the incorrect use of NewFuncInfo/NewFileInfo. Change-Id: I7e7ea9822ff9a1e7140f5e5b7cfd6437ff9318a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/266338 Trust: Russ Cox Run-TryBot: Russ Cox Reviewed-by: Cherry Zhang TryBot-Result: Go Bot --- src/cmd/internal/obj/link.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go index b578b6a09a..c652e3adbb 100644 --- a/src/cmd/internal/obj/link.go +++ b/src/cmd/internal/obj/link.go @@ -38,7 +38,6 @@ import ( "cmd/internal/src" "cmd/internal/sys" "fmt" - "log" "sync" ) @@ -471,7 +470,7 @@ type FuncInfo struct { // NewFuncInfo allocates and returns a FuncInfo for LSym. func (s *LSym) NewFuncInfo() *FuncInfo { if s.Extra != nil { - log.Fatalf("invalid use of LSym - NewFuncInfo with Extra of type %T", *s.Extra) + panic(fmt.Sprintf("invalid use of LSym - NewFuncInfo with Extra of type %T", *s.Extra)) } f := new(FuncInfo) s.Extra = new(interface{}) @@ -498,7 +497,7 @@ type FileInfo struct { // NewFileInfo allocates and returns a FileInfo for LSym. func (s *LSym) NewFileInfo() *FileInfo { if s.Extra != nil { - log.Fatalf("invalid use of LSym - NewFileInfo with Extra of type %T", *s.Extra) + panic(fmt.Sprintf("invalid use of LSym - NewFileInfo with Extra of type %T", *s.Extra)) } f := new(FileInfo) s.Extra = new(interface{}) -- 2.48.1