golang/go

cmd/compile: internal compiler error: panic during short circuit

Closed this issue · 2 comments

$ gotip version
go version devel go1.17-da7496d841 Tue May 4 17:37:39 2021 +0000 linux/amd64
package p

func f() {
	_ = func() func() {
		return func() {
		l:
			goto l
		}
	}()
}
$ gotip tool compile crash.go

crash.go:9:3: internal compiler error: 'f.func2': panic during short circuit while compiling f.func2:

runtime error: index out of range [0] with length 0

goroutine 9 [running]:
cmd/compile/internal/ssa.Compile.func1()
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:48 +0x71
panic({0xcb8f80, 0xc000026b10})
	/home/alberto/go/src/runtime/panic.go:1038 +0x215
cmd/compile/internal/ssa.fuseBlockPlain(0x725c20)
	/home/alberto/go/src/cmd/compile/internal/ssa/fuse.go:178 +0x554
cmd/compile/internal/ssa.fuse(0xc00037dd40, 0x11)
	/home/alberto/go/src/cmd/compile/internal/ssa/fuse.go:41 +0x19d
cmd/compile/internal/ssa.shortcircuit(0xc00037dd40)
	/home/alberto/go/src/cmd/compile/internal/ssa/shortcircuit.go:61 +0x85
cmd/compile/internal/ssa.Compile(0xc00037dd40)
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:96 +0x9e7
cmd/compile/internal/ssagen.buildssa(0xc00013ab00, 0x0)
	/home/alberto/go/src/cmd/compile/internal/ssagen/ssa.go:642 +0x1ddd
cmd/compile/internal/ssagen.Compile(0xc00013ab00, 0x0)
	/home/alberto/go/src/cmd/compile/internal/ssagen/pgen.go:165 +0x4c
cmd/compile/internal/gc.compileFunctions.func2.1()
	/home/alberto/go/src/cmd/compile/internal/gc/compile.go:136 +0x65
created by cmd/compile/internal/gc.compileFunctions.func2
	/home/alberto/go/src/cmd/compile/internal/gc/compile.go:134 +0xcf

The program compiles fine in Go1.16.

Reduced from a gosmith crasher.

cc @mdempsky

Seems like another case of inlining and function closures.

/cc @danscales

Change https://golang.org/cl/316931 mentions this issue: cmd/compile: do not substitute OGOTO inside a closure when inlining