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: ssa panics on a continue in a switch without a loop #19934

Closed
mvdan opened this issue Apr 11, 2017 · 3 comments
Closed

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

mvdan opened this issue Apr 11, 2017 · 3 comments
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Apr 11, 2017

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.

@mvdan mvdan added this to the Go1.9 milestone Apr 11, 2017
@mvdan
Copy link
Member Author

mvdan commented Apr 11, 2017

Confirming the commit above is to blame; its tree panics, its parent's tree does not. Will look around the code in case the fix is somewhat easy.

Also not sure how to feel about being the only one who writes garbage code on tip.

@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 11, 2017
@mvdan mvdan changed the title cmd/compile: ssa nil pointer dereference crash on tip cmd/compile: ssa panics on a continue in a switch without a loop Apr 11, 2017
@mvdan
Copy link
Member Author

mvdan commented Apr 11, 2017

Okay, found a fix. Mailing CL with test soon.

@mvdan mvdan assigned mvdan and unassigned josharian Apr 11, 2017
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/40357 mentions this issue.

@mvdan mvdan removed the NeedsFix The path to resolution is known, but the work has not been done. label Apr 12, 2017
@golang golang locked and limited conversation to collaborators Apr 12, 2018
@rsc rsc unassigned mvdan Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants