mirror of
https://github.com/golang/go.git
synced 2026-01-29 07:02:05 +03:00
runtime: do not print recovered when double panic with the same value
Show the "[recovered, repanicked]" message only when it is repanicked after recovered. For the duplicated panics that not recovered, do not show this message. Fixes #76099 Change-Id: I87282022ebe44c6f6efbe3239218be4a2a7b1104 Reviewed-on: https://go-review.googlesource.com/c/go/+/716020 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
9859b43643
commit
c93766007d
@@ -413,6 +413,15 @@ func TestRepanickedPanicSandwich(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoublePanicWithSameValue(t *testing.T) {
|
||||
output := runTestProg(t, "testprog", "DoublePanicWithSameValue")
|
||||
want := `panic: message
|
||||
`
|
||||
if !strings.HasPrefix(output, want) {
|
||||
t.Fatalf("output does not start with %q:\n%s", want, output)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoexitCrash(t *testing.T) {
|
||||
// External linking brings in cgo, causing deadlock detection not working.
|
||||
testenv.MustInternalLink(t, deadlockBuildTypes)
|
||||
|
||||
@@ -739,7 +739,7 @@ func printpanics(p *_panic) {
|
||||
}
|
||||
print("panic: ")
|
||||
printpanicval(p.arg)
|
||||
if p.repanicked {
|
||||
if p.recovered && p.repanicked {
|
||||
print(" [recovered, repanicked]")
|
||||
} else if p.recovered {
|
||||
print(" [recovered]")
|
||||
|
||||
11
src/runtime/testdata/testprog/crash.go
vendored
11
src/runtime/testdata/testprog/crash.go
vendored
@@ -22,6 +22,7 @@ func init() {
|
||||
register("RepanickedPanic", RepanickedPanic)
|
||||
register("RepanickedMiddlePanic", RepanickedMiddlePanic)
|
||||
register("RepanickedPanicSandwich", RepanickedPanicSandwich)
|
||||
register("DoublePanicWithSameValue", DoublePanicWithSameValue)
|
||||
}
|
||||
|
||||
func test(name string) {
|
||||
@@ -189,3 +190,13 @@ func RepanickedPanicSandwich() {
|
||||
panic("outer")
|
||||
}()
|
||||
}
|
||||
|
||||
// Double panic with same value and not recovered.
|
||||
// See issue 76099.
|
||||
func DoublePanicWithSameValue() {
|
||||
var e any = "message"
|
||||
defer func() {
|
||||
panic(e)
|
||||
}()
|
||||
panic(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user