Skip to content

cmd/compile: internal compiler error: val is in reg but not live (with ssa checks on) #31915

Closed
@ALTree

Description

@ALTree
$ gotip version
go version devel +4cd6c3bac7 Wed May 8 16:00:05 2019 +0000 linux/amd64

When compiled with the ssa checks enabled (-d=ssa/check/on), the following program:

package p

//go:noinline
func f() {}

func g() {
	var a []int
	var b bool
	for {
		b = (b && b) != (b && b)
		for b && b == b || true {
			f()
			_ = a[0]
		}
		_ = &b
		a = []int{}
	}
}

crashes the tip compiler with this error:

$ gotip tool compile -d=ssa/check/on crash.go

crash.go:11:9: internal compiler error: 'g': val v46 is in reg but not live at end of b10

goroutine 1 [running]:
runtime/debug.Stack(0xfce340, 0xc00000e018, 0x0)
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0xc00001c6c0, 0x30, 0xc0003076e0, 0x3, 0x3)
	/home/alberto/go/src/cmd/compile/internal/gc/subr.go:188 +0x291
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc000306cf0, 0xb09000000002, 0xe43d6b, 0x2a, 0xc000343420, 0x2, 0x2)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:6081 +0x1b0
cmd/compile/internal/ssa.(*Func).Fatalf(...)
	/home/alberto/go/src/cmd/compile/internal/ssa/func.go:616
cmd/compile/internal/ssa.(*regAllocState).regalloc(0xc000001800, 0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/regalloc.go:1598 +0x3e14
cmd/compile/internal/ssa.regalloc(0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/regalloc.go:146 +0x62
cmd/compile/internal/ssa.Compile(0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:90 +0x476
cmd/compile/internal/gc.buildssa(0xc0002ac2c0, 0x0, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:288 +0xbe9
cmd/compile/internal/gc.compileSSA(0xc0002ac2c0, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:297 +0x4d
cmd/compile/internal/gc.compile(0xc0002ac2c0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:276 +0x33d
cmd/compile/internal/gc.funccompile(0xc0002ac2c0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:221 +0xc1
cmd/compile/internal/gc.Main(0xe4ef50)
	/home/alberto/go/src/cmd/compile/internal/gc/main.go:676 +0x30e5
main.main()
	/home/alberto/go/src/cmd/compile/main.go:51 +0xac

without -d=ssa/check/on, there is no crash.

The 1.12 and 1.11 compilers are also affected. The 1.10 compiler seems to be okay.

cc @randall77 @cherrymui

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions