diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index 2b8ca549ad8..00e67aeca0c 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -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) diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 3c967a29997..62affac5f95 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -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]") diff --git a/src/runtime/testdata/testprog/crash.go b/src/runtime/testdata/testprog/crash.go index 556215a71ea..fcce3888711 100644 --- a/src/runtime/testdata/testprog/crash.go +++ b/src/runtime/testdata/testprog/crash.go @@ -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) +}