mirror of
https://github.com/golang/go
synced 2024-11-11 20:20:23 -07:00
runtime: fix defer of nil func
Fixes #8047. LGTM=r, iant R=golang-codereviews, r, iant CC=dvyukov, golang-codereviews, khr https://golang.org/cl/105140044
This commit is contained in:
parent
83c8140662
commit
36207a91d3
@ -856,7 +856,12 @@ runtime·newstack(void)
|
||||
void
|
||||
runtime·gostartcallfn(Gobuf *gobuf, FuncVal *fv)
|
||||
{
|
||||
runtime·gostartcall(gobuf, fv->fn, fv);
|
||||
void *fn;
|
||||
|
||||
fn = nil;
|
||||
if(fv != nil)
|
||||
fn = fv->fn;
|
||||
runtime·gostartcall(gobuf, fn, fv);
|
||||
}
|
||||
|
||||
// Maybe shrink the stack being used by gp.
|
||||
|
22
test/fixedbugs/issue8047b.go
Normal file
22
test/fixedbugs/issue8047b.go
Normal file
@ -0,0 +1,22 @@
|
||||
// run
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Issue 8047. Defer setup during panic shouldn't crash for nil defer.
|
||||
|
||||
package main
|
||||
|
||||
func main() {
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
f()
|
||||
}
|
||||
|
||||
func f() {
|
||||
var g func()
|
||||
defer g()
|
||||
panic(1)
|
||||
}
|
Loading…
Reference in New Issue
Block a user