]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Record jmpdefer's argument size.
authorKeith Randall <khr@golang.org>
Wed, 7 Aug 2013 21:03:50 +0000 (14:03 -0700)
committerKeith Randall <khr@golang.org>
Wed, 7 Aug 2013 21:03:50 +0000 (14:03 -0700)
Fixes bug 6055.

R=golang-dev, bradfitz, dvyukov, khr
CC=golang-dev
https://golang.org/cl/12536045

src/pkg/runtime/asm_386.s
src/pkg/runtime/asm_amd64.s
src/pkg/runtime/asm_arm.s
test/fixedbugs/issue6055.go [new file with mode: 0644]

index 904287e69e8babb07ea03d81fa4e8e05b69d11d5..c61b75cfb22fed7ceb86f2f1de21a6c585cec328 100644 (file)
@@ -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
index 391a1129d9edb6131773839baf53b70ceb75aaa8..fcc75a9229d1dde5e184e5337ecaed27fd3c20ee 100644 (file)
@@ -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
index d02ba6b031cc22fa32c978f03ffdedb5e5607122..bc23b454df39b3abd14e222ca0f0edda70751d7d 100644 (file)
@@ -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 (file)
index 0000000..4cc24d0
--- /dev/null
@@ -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)
+}