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: crash inlining function with SWITCH with labeled breaks/continues #49145

Closed
wdvxdr1123 opened this issue Oct 25, 2021 · 1 comment
Closed
Labels
Milestone

Comments

@wdvxdr1123
Copy link
Contributor

@wdvxdr1123 wdvxdr1123 commented Oct 25, 2021

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

$ go version
go version devel go1.18-7b554575e46 Mon Oct 25 03:00:02 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

no

What did you do?

package main

func f(j int) {
loop:
	switch j {
	case 1:
        break loop
	default:
		println(j)
    }
}

func main() {
loop:
	for j := 0; j < 5; j++ {
		f(j)
		if j == 3 {
			break loop
		}
	}
}

What did you expect to see?

0
2
3

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x30 pc=0xee06a1]

goroutine 19 [running]:
cmd/compile/internal/ssa.(*Block).AddEdgeTo(...)
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssa/block.go:274
cmd/compile/internal/ssagen.(*state).stmt(0xc000128300, {0x12dd090, 0xc000806150})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1731 +0x1461
cmd/compile/internal/ssagen.(*state).stmtList(0x10ffae0, {0xc00009c3f0, 0x9, 0x4})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1374 +0x5d
cmd/compile/internal/ssagen.(*state).stmt(0xc000128300, {0x12df480, 0xc000816080})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1850 +0x39d8
cmd/compile/internal/ssagen.(*state).stmtList(0xc000128300, {0xc0000a2400, 0x7, 0x4})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1374 +0x5d
cmd/compile/internal/ssagen.(*state).stmt(0xc000128300, {0x12dd9f0, 0xc00016c360})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1781 +0x20c9
cmd/compile/internal/ssagen.(*state).stmtList(0xc000128300, {0xc0000a42c0, 0x4, 0x0})
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:1374 +0x5d
cmd/compile/internal/ssagen.buildssa(0xc0003fec60, 0x1)
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/ssa.go:567 +0x1d13
cmd/compile/internal/ssagen.Compile(0xc0003fec60, 0xc000413f90)
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/ssagen/pgen.go:183 +0x4c
cmd/compile/internal/gc.compileFunctions.func4.1(0x0)
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/gc/compile.go:153 +0x3a
cmd/compile/internal/gc.compileFunctions.func3.1()
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/gc/compile.go:140 +0x4d
created by cmd/compile/internal/gc.compileFunctions.func3
C:/Users/wdvxdr/Documents/Project/go/src/cmd/compile/internal/gc/compile.go:138 +0x78

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 25, 2021

Change https://golang.org/cl/358315 mentions this issue: cmd/compile: fix inlining labeled switch statements

Loading

@ALTree ALTree added this to the Go1.18 milestone Oct 25, 2021
@gopherbot gopherbot closed this in c6e82e5 Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants