golang/go

cmd/compile: panic: log2 of 0 on arm64

ALTree opened this issue · 2 comments

$ gotip version
go version devel +176481990f Thu May 7 07:06:11 2020 +0000 linux/amd64
go version go1.14.2 linux/amd64
go version go1.13.10 linux/amd64

This program:

package p

func f() {
	var r rune
	var b bool

	g := func() bool {
		b = b
		return ('0' & 'る') < (*&r)&^(r&^r)
	}

	b = g() || b
}

Crashes the Go1.13.10, the Go1.14.2, and the tip compilers, when built for arm64, with the following error:

$ GOARCH=arm64 gotip build crash.go 

# command-line-arguments
panic: log2 of 0

goroutine 50 [running]:
cmd/internal/obj/arm64.log2(...)
	/home/alberto/go/src/cmd/internal/obj/arm64/asm7.go:1456
cmd/internal/obj/arm64.bitconEncode(0xffffffffffffffff, 0x20, 0x4b9802923)
	/home/alberto/go/src/cmd/internal/obj/arm64/asm7.go:1436 +0x2ef
cmd/internal/obj/arm64.(*ctxt7).asmout(0xc0003fdd50, 0xc0001fa5d0, 0x108a34c, 0xc0003fdca8, 0x6, 0x6)
	/home/alberto/go/src/cmd/internal/obj/arm64/asm7.go:3910 +0x4954
cmd/internal/obj/arm64.span7(0xc00016f6c0, 0xc0005bc900, 0xc000044d20)
	/home/alberto/go/src/cmd/internal/obj/arm64/asm7.go:1062 +0xb26
cmd/internal/obj.Flushplist(0xc00016f6c0, 0xc0003fdea8, 0xc000044d20, 0x7ffeba1d52c3, 0x16)
	/home/alberto/go/src/cmd/internal/obj/plist.go:107 +0x76d
cmd/compile/internal/gc.(*Progs).Flush(0xc0003f2500)
	/home/alberto/go/src/cmd/compile/internal/gc/gsubr.go:98 +0xbd
cmd/compile/internal/gc.compileSSA(0xc0001362c0, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:321 +0x68e
cmd/compile/internal/gc.compileFunctions.func2(0xc000589440, 0xc00058a240, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:361 +0x4d
created by cmd/compile/internal/gc.compileFunctions
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:359 +0x129

Tentatively marking as a release blocker since it's a compiler crasher in a First Class Port, but leaving for others to decide if this is fine (it's not a tip regression).

cc @randall77

According to bisection, the culprit seems to be 86ce1cb

Change https://golang.org/cl/232984 mentions this issue: cmd/internal/obj/arm64: fix 32-bit BITCON test