File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -444,6 +444,13 @@ func TestPanicDeadlockSyscall(t *testing.T) {
444
444
testPanicDeadlock (t , "SyscallInPanic" , "1\n 2\n panic: 3\n \n " )
445
445
}
446
446
447
+ func TestPanicLoop (t * testing.T ) {
448
+ output := runTestProg (t , "testprog" , "PanicLoop" )
449
+ if want := "panic while printing panic value" ; ! strings .Contains (output , want ) {
450
+ t .Errorf ("output does not contain %q:\n %s" , want , output )
451
+ }
452
+ }
453
+
447
454
func TestMemPprof (t * testing.T ) {
448
455
testenv .MustHaveGoRun (t )
449
456
Original file line number Diff line number Diff line change @@ -376,6 +376,11 @@ func Goexit() {
376
376
// Used when crashing with panicking.
377
377
// This must match types handled by printany.
378
378
func preprintpanics (p * _panic ) {
379
+ defer func () {
380
+ if recover () != nil {
381
+ throw ("panic while printing panic value" )
382
+ }
383
+ }()
379
384
for p != nil {
380
385
switch v := p .arg .(type ) {
381
386
case error :
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ func init() {
32
32
register ("PanicTraceback" , PanicTraceback )
33
33
register ("GoschedInPanic" , GoschedInPanic )
34
34
register ("SyscallInPanic" , SyscallInPanic )
35
+ register ("PanicLoop" , PanicLoop )
35
36
}
36
37
37
38
func SimpleDeadlock () {
@@ -214,3 +215,13 @@ func pt2() {
214
215
}()
215
216
panic ("hello" )
216
217
}
218
+
219
+ type panicError struct {}
220
+
221
+ func (* panicError ) Error () string {
222
+ panic ("double error" )
223
+ }
224
+
225
+ func PanicLoop () {
226
+ panic (& panicError {})
227
+ }
You can’t perform that action at this time.
0 commit comments