Skip to content

cmd/compile: ssa panics on a continue in a switch without a loop #19934

@mvdan

Description

@mvdan

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

go version devel +69261ecad6 Tue Apr 11 12:25:55 2017 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

not relevant

What did you do?

Build f.go (reduced manually):

package foo

func Foo(a string) {
        switch a {
        case "b":
                continue
        }
}

What did you expect to see?

What Go 1.8.1 gives:

./f.go:6: continue is not in a loop

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa248e4]

goroutine 1 [running]:
cmd/compile/internal/ssa.(*Block).AddEdgeTo(...)
        /home/mvdan/tip/src/cmd/compile/internal/ssa/block.go:150
cmd/compile/internal/gc.(*state).stmt(0xc4202a60e0, 0xc4202f21b0)
        /home/mvdan/tip/src/cmd/compile/internal/gc/ssa.go:783 +0x11e4
cmd/compile/internal/gc.(*state).stmtList(0xc4202a60e0, 0xc42034a040)
        /home/mvdan/tip/src/cmd/compile/internal/gc/ssa.go:503 +0x5a
cmd/compile/internal/gc.(*state).stmt(0xc4202a60e0, 0xc4202f2090)
        /home/mvdan/tip/src/cmd/compile/internal/gc/ssa.go:878 +0x48f4
cmd/compile/internal/gc.(*state).stmtList(0xc4202a60e0, 0xc4202c1fe0)
        /home/mvdan/tip/src/cmd/compile/internal/gc/ssa.go:503 +0x5a
cmd/compile/internal/gc.buildssa(0xc42009e280, 0x0)
        /home/mvdan/tip/src/cmd/compile/internal/gc/ssa.go:189 +0x84b
cmd/compile/internal/gc.compile(0xc42009e280)
        /home/mvdan/tip/src/cmd/compile/internal/gc/pgen.go:301 +0x112
cmd/compile/internal/gc.funccompile(0xc42009e280)
        /home/mvdan/tip/src/cmd/compile/internal/gc/dcl.go:1054 +0xb7
cmd/compile/internal/gc.Main(0xb9d528)
        /home/mvdan/tip/src/cmd/compile/internal/gc/main.go:545 +0x25e5
main.main()
        /home/mvdan/tip/src/cmd/compile/main.go:49 +0x95

Placing my bets on c03e75e by @josharian, will try that version its parent and report back.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions