diff options
| author | qiulaidongfeng <2645477756@qq.com> | 2024-09-17 20:10:20 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-07 12:55:37 -0800 |
| commit | 5cd1b73772e339e3b460d53ba37630704a323ca7 (patch) | |
| tree | 5ea82544483a8a1501217e9cbe9df451c5ab014b /src/runtime/testdata | |
| parent | 91ca80f970c2a20d1ed6603281c97e7e617b87e8 (diff) | |
| download | go-5cd1b73772e339e3b460d53ba37630704a323ca7.tar.xz | |
runtime: correctly print panics before fatal-ing on defer
Fixes #67792
Change-Id: I93d16580cb31e54cee7c8490212404e4d0dec446
Reviewed-on: https://go-review.googlesource.com/c/go/+/613757
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/testdata')
| -rw-r--r-- | src/runtime/testdata/testprog/panicprint.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/panicprint.go b/src/runtime/testdata/testprog/panicprint.go index 4ce958ba3d..eaf3ba2c33 100644 --- a/src/runtime/testdata/testprog/panicprint.go +++ b/src/runtime/testdata/testprog/panicprint.go @@ -4,6 +4,8 @@ package main +import "sync" + type MyBool bool type MyComplex128 complex128 type MyComplex64 complex64 @@ -90,6 +92,23 @@ func panicCustomFloat32() { panic(MyFloat32(-93.70)) } +func panicDeferFatal() { + var mu sync.Mutex + defer mu.Unlock() + var i *int + *i = 0 +} + +func panicDoublieDeferFatal() { + var mu sync.Mutex + defer mu.Unlock() + defer func() { + panic(recover()) + }() + var i *int + *i = 0 +} + func init() { register("panicCustomComplex64", panicCustomComplex64) register("panicCustomComplex128", panicCustomComplex128) @@ -108,4 +127,6 @@ func init() { register("panicCustomUint32", panicCustomUint32) register("panicCustomUint64", panicCustomUint64) register("panicCustomUintptr", panicCustomUintptr) + register("panicDeferFatal", panicDeferFatal) + register("panicDoublieDeferFatal", panicDoublieDeferFatal) } |
