golang/go

cmd/compile: internal compiler error: panic during lower (integer divide by zero)

ALTree opened this issue · 1 comments

go version go1.14.13 linux/amd64
go version go1.15.6 linux/amd64
go version devel +854a2f8e01 Wed Dec 9 03:06:41 2020 +0000 linux/amd64

The following program:

package p

func f() {
	var i int
	var s string
	for i > 0 {
		_ = s[0]
		i++
	}

	var c chan int
	c <- 1 % i
}

Crashes the 1.14, 1.15, and tip compilers, when compiled for arm, mips, or mipsle, with this error:

$ GOARCH=arm go tool compile crash.go

crash.go:6:10: internal compiler error: 'f': panic during lower while compiling f:

runtime error: integer divide by zero

goroutine 1 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc00045c550, 0xc0001506e0)
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:48 +0xa5
panic(0xc34f20, 0x11182c0)
	/home/alberto/go/src/runtime/panic.go:965 +0x1b9
cmd/compile/internal/ssa.rewriteValueARM_OpSelect1(0xc000400a10, 0xc000400400)
	/home/alberto/go/src/cmd/compile/internal/ssa/rewriteARM.go:15681 +0x1f7
cmd/compile/internal/ssa.rewriteValueARM(0xc000400a10, 0xc000000000)
	/home/alberto/go/src/cmd/compile/internal/ssa/rewriteARM.go:807 +0x3e7d

[...]

Tentatively putting in the 1.16 milestone, pending investigation.

cc @randall77

Change https://golang.org/cl/276652 mentions this issue: cmd/compile: don't constant fold divide by zero