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>
}
}
+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)
}
print("panic: ")
printpanicval(p.arg)
- if p.repanicked {
+ if p.recovered && p.repanicked {
print(" [recovered, repanicked]")
} else if p.recovered {
print(" [recovered]")
register("RepanickedPanic", RepanickedPanic)
register("RepanickedMiddlePanic", RepanickedMiddlePanic)
register("RepanickedPanicSandwich", RepanickedPanicSandwich)
+ register("DoublePanicWithSameValue", DoublePanicWithSameValue)
}
func test(name string) {
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)
+}