From: Keith Randall Date: Wed, 7 Aug 2013 21:03:50 +0000 (-0700) Subject: runtime: Record jmpdefer's argument size. X-Git-Tag: go1.2rc2~735 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a97a91de06b3f071a08314c7cb54eac57c4a624a;p=gostls13.git runtime: Record jmpdefer's argument size. Fixes bug 6055. R=golang-dev, bradfitz, dvyukov, khr CC=golang-dev https://golang.org/cl/12536045 --- diff --git a/src/pkg/runtime/asm_386.s b/src/pkg/runtime/asm_386.s index 904287e69e..c61b75cfb2 100644 --- a/src/pkg/runtime/asm_386.s +++ b/src/pkg/runtime/asm_386.s @@ -537,7 +537,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-12 // 1. pop the caller // 2. sub 5 bytes from the callers return // 3. jmp to the argument -TEXT runtime·jmpdefer(SB), NOSPLIT, $0 +TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 MOVL 4(SP), DX // fn MOVL 8(SP), BX // caller sp LEAL -4(BX), SP // caller sp after CALL diff --git a/src/pkg/runtime/asm_amd64.s b/src/pkg/runtime/asm_amd64.s index 391a1129d9..fcc75a9229 100644 --- a/src/pkg/runtime/asm_amd64.s +++ b/src/pkg/runtime/asm_amd64.s @@ -577,7 +577,7 @@ TEXT runtime·atomicstore64(SB), NOSPLIT, $0-16 // 1. pop the caller // 2. sub 5 bytes from the callers return // 3. jmp to the argument -TEXT runtime·jmpdefer(SB), NOSPLIT, $0 +TEXT runtime·jmpdefer(SB), NOSPLIT, $0-16 MOVQ 8(SP), DX // fn MOVQ 16(SP), BX // caller sp LEAQ -8(BX), SP // caller sp after CALL diff --git a/src/pkg/runtime/asm_arm.s b/src/pkg/runtime/asm_arm.s index d02ba6b031..bc23b454df 100644 --- a/src/pkg/runtime/asm_arm.s +++ b/src/pkg/runtime/asm_arm.s @@ -367,7 +367,7 @@ TEXT runtime·lessstack(SB), NOSPLIT, $-4-0 // 1. grab stored LR for caller // 2. sub 4 bytes to get back to BL deferreturn // 3. B to fn -TEXT runtime·jmpdefer(SB), NOSPLIT, $0 +TEXT runtime·jmpdefer(SB), NOSPLIT, $0-8 MOVW 0(SP), LR MOVW $-4(LR), LR // BL deferreturn MOVW fn+0(FP), R7 diff --git a/test/fixedbugs/issue6055.go b/test/fixedbugs/issue6055.go new file mode 100644 index 0000000000..4cc24d0c2c --- /dev/null +++ b/test/fixedbugs/issue6055.go @@ -0,0 +1,29 @@ +// run + +// Copyright 2013 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. + +package main + +type Closer interface { + Close() +} + +func nilInterfaceDeferCall() { + var x Closer + defer x.Close() +} + +func shouldPanic(f func()) { + defer func() { + if recover() == nil { + panic("did not panic") + } + }() + f() +} + +func main() { + shouldPanic(nilInterfaceDeferCall) +}