File tree Expand file tree Collapse file tree 5 files changed +160
-11
lines changed Expand file tree Collapse file tree 5 files changed +160
-11
lines changed Original file line number Diff line number Diff line change @@ -1142,18 +1142,21 @@ func gorecover(_ uintptr) any {
1142
1142
nonWrapperFrames := 0
1143
1143
loop:
1144
1144
for ; u .valid (); u .next () {
1145
- switch u .frame .fn .funcID {
1146
- case abi .FuncIDWrapper :
1147
- continue
1148
- case abi .FuncID_gopanic :
1149
- if u .frame .fp == uintptr (p .gopanicFP ) && nonWrapperFrames > 0 {
1150
- canRecover = true
1151
- }
1152
- break loop
1153
- default :
1154
- nonWrapperFrames ++
1155
- if nonWrapperFrames > 1 {
1145
+ for iu , f := newInlineUnwinder (u .frame .fn , u .symPC ()); f .valid (); f = iu .next (f ) {
1146
+ sf := iu .srcFunc (f )
1147
+ switch sf .funcID {
1148
+ case abi .FuncIDWrapper :
1149
+ continue
1150
+ case abi .FuncID_gopanic :
1151
+ if u .frame .fp == uintptr (p .gopanicFP ) && nonWrapperFrames > 0 {
1152
+ canRecover = true
1153
+ }
1156
1154
break loop
1155
+ default :
1156
+ nonWrapperFrames ++
1157
+ if nonWrapperFrames > 1 {
1158
+ break loop
1159
+ }
1157
1160
}
1158
1161
}
1159
1162
}
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2025 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ func callRecover () {
10
+ if recover () != nil {
11
+ println ("recovered" )
12
+ }
13
+ }
14
+
15
+ func F (int ) { callRecover () }
16
+
17
+ func main () {
18
+ mustPanic (func () {
19
+ defer F (1 )
20
+ panic ("XXX" )
21
+ })
22
+ }
23
+
24
+ func mustPanic (f func ()) {
25
+ defer func () {
26
+ r := recover ()
27
+ if r == nil {
28
+ panic ("didn't panic" )
29
+ }
30
+ }()
31
+ f ()
32
+ }
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2025 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ func callRecover () {
10
+ func () {
11
+ if recover () != nil {
12
+ println ("recovered" )
13
+ }
14
+ }()
15
+ }
16
+
17
+ func F () int { callRecover (); return 0 }
18
+
19
+ func main () {
20
+ mustPanic (func () {
21
+ defer F ()
22
+ panic ("XXX" )
23
+ })
24
+ }
25
+
26
+ func mustPanic (f func ()) {
27
+ defer func () {
28
+ r := recover ()
29
+ if r == nil {
30
+ panic ("didn't panic" )
31
+ }
32
+ }()
33
+ f ()
34
+ }
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2025 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ func callRecover () {
10
+ if recover () != nil {
11
+ println ("recovered" )
12
+ }
13
+ }
14
+
15
+ type T int
16
+
17
+ func (* T ) M () { callRecover () }
18
+
19
+ type S struct { * T } // has a wrapper S.M wrapping (*T.M)
20
+
21
+ var p = S {new (T )}
22
+
23
+ var fn = S .M // using a function pointer to force using the wrapper
24
+
25
+ func main () {
26
+ mustPanic (func () {
27
+ defer fn (p )
28
+ panic ("XXX" )
29
+ })
30
+ }
31
+
32
+ func mustPanic (f func ()) {
33
+ defer func () {
34
+ r := recover ()
35
+ if r == nil {
36
+ panic ("didn't panic" )
37
+ }
38
+ }()
39
+ f ()
40
+ }
Original file line number Diff line number Diff line change
1
+ // run
2
+
3
+ // Copyright 2025 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package main
8
+
9
+ func callRecover () {
10
+ if recover () != nil {
11
+ println ("recovered" )
12
+ }
13
+ }
14
+
15
+ type T int
16
+
17
+ func (* T ) M () { callRecover () }
18
+
19
+ type S struct { * T } // has a wrapper (*S).M wrapping (*T.M)
20
+
21
+ var p = & S {new (T )}
22
+
23
+ var fn = (* S ).M // using a function pointer to force using the wrapper
24
+
25
+ func main () {
26
+ mustPanic (func () {
27
+ defer fn (p )
28
+ panic ("XXX" )
29
+ })
30
+ }
31
+
32
+ func mustPanic (f func ()) {
33
+ defer func () {
34
+ r := recover ()
35
+ if r == nil {
36
+ panic ("didn't panic" )
37
+ }
38
+ }()
39
+ f ()
40
+ }
You can’t perform that action at this time.
0 commit comments