Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: "Open defer" of method call miscompiled at tip #45062

dr2chase opened this issue Mar 16, 2021 · 1 comment

cmd/compile: "Open defer" of method call miscompiled at tip #45062

dr2chase opened this issue Mar 16, 2021 · 1 comment


Copy link

@dr2chase dr2chase commented Mar 16, 2021

What version of Go are you using (go version)?

This is for Go 1.17 development, the bug appears at

Does this issue reproduce with the latest release?

It is not seen in 1.16.

What did you do?

Playground shows expected behavior.

package main

func main() {
	var x, y, z int = -1, -2, -3
	F(x, y, z)

func F(x, y, z int) {
	defer i.M(x, y, z)
	defer func() { recover() }()

type T int
func (t *T) M(x, y, z int) { println(t, *t, x, y, z) }

var t T = 42

type I interface{ M(x, y, z int) }
var i I = &t

What did you see instead?

unexpected fault address 0xffffffffffffffff
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xffffffffffffffff pc=0x105f046]

goroutine 1 [running]:
runtime.throw(0x10749df, 0x5)
	/Users/drchase/work/go/src/runtime/panic.go:1126 +0x74 fp=0xc000032540 sp=0xc000032510 pc=0x102f614
	/Users/drchase/work/go/src/runtime/signal_unix.go:742 +0x3e5 fp=0xc0000325a0 sp=0xc000032540 pc=0x1045145
main.(*T).M(0xffffffffffffffff, 0xfffffffffffffffe, 0xfffffffffffffffd, 0x0)
	/Users/drchase/work/tmp/g3b.go:16 +0x26 fp=0xc0000325c0 sp=0xc0000325a0 pc=0x105f046
runtime.call32(0x0, 0x108b4e0, 0xc000058048, 0x2000000020, 0x20, 0xc000032620)
	/Users/drchase/work/go/src/runtime/asm_amd64.s:604 +0x49 fp=0xc0000325f0 sp=0xc0000325c0 pc=0x105a169
runtime.reflectcallSave(0x0, 0x108b4e0, 0xc000058048, 0x20)
	/Users/drchase/work/go/src/runtime/panic.go:884 +0x66 fp=0xc000032630 sp=0xc0000325f0 pc=0x102eba6
runtime.runOpenDeferFrame(0xc000000180, 0xc000058000, 0x1066420)
	/Users/drchase/work/go/src/runtime/panic.go:852 +0x625 fp=0xc0000326b8 sp=0xc000032630 pc=0x102e885
	/Users/drchase/work/go/src/runtime/panic.go:536 +0x135 fp=0xc000032708 sp=0xc0000326b8 pc=0x102d9f5
main.F(0xffffffffffffffff, 0xfffffffffffffffe, 0xfffffffffffffffd)
	/Users/drchase/work/tmp/bug.go:12 +0xab fp=0xc000032760 sp=0xc000032708 pc=0x105f00b
	/Users/drchase/work/tmp/bug.go:5 +0x3c fp=0xc000032788 sp=0xc000032760 pc=0x105ef3c
	/Users/drchase/work/go/src/runtime/proc.go:225 +0x256 fp=0xc0000327e0 sp=0xc000032788 pc=0x10321b6
	/Users/drchase/work/go/src/runtime/asm_amd64.s:1448 +0x1 fp=0xc0000327e8 sp=0xc0000327e0 pc=0x105bca1

Root cause is failure to account for receiver at index zero when processing parameters, a CL is in the works.

@dr2chase dr2chase self-assigned this Mar 16, 2021
@dmitshur dmitshur added this to the Go1.17 milestone Mar 16, 2021
Copy link

@gopherbot gopherbot commented Mar 16, 2021

Change mentions this issue: cmd/compile: fix open defer of method call


@gopherbot gopherbot closed this in d206ca5 Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants