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: internal compiler error: Value live at entry. It shouldn't be. #45706

Closed
ALTree opened this issue Apr 22, 2021 · 5 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Apr 22, 2021

$ gotip version
go version devel go1.17-e8666abd98 Thu Apr 22 16:38:37 2021 +0000 linux/amd64
package p

var i int
var arr []*int
var f func() int

func g() {
	for i, *(arr[f()]) = range []int{} {
	}
}
$ gotip tool compile crash.go 
crash2.go:7:6: internal compiler error: 'g': Value live at entry. It shouldn't be. func g, node .autotmp_1, value v58

goroutine 21 [running]:
runtime/debug.Stack()
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt(0x12a3238, 0xc0000f82d0, 0x30, 0xc0000c3f00, 0x30, 0x7f9b553715b8)
	/home/alberto/go/src/cmd/compile/internal/base/print.go:227 +0x157
cmd/compile/internal/base.Fatalf(...)
	/home/alberto/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x12a3238, 0x1, 0xd42985, 0xe813a8, 0xc000377500, 0x3, 0x413705)
	/home/alberto/go/src/cmd/compile/internal/ssagen/ssa.go:7481 +0x187
cmd/compile/internal/ssagen.(*state).Fatalf(...)
	/home/alberto/go/src/cmd/compile/internal/ssagen/ssa.go:976
cmd/compile/internal/ssagen.(*simplePhiState).insertPhis(0xc0000cda40)
	/home/alberto/go/src/cmd/compile/internal/ssagen/phi.go:486 +0x283
cmd/compile/internal/ssagen.(*state).insertPhis(0xc000367860)
	/home/alberto/go/src/cmd/compile/internal/ssagen/phi.go:45 +0x166
cmd/compile/internal/ssagen.buildssa(0x406307, 0x0)
	/home/alberto/go/src/cmd/compile/internal/ssagen/ssa.go:637 +0x1d1f
cmd/compile/internal/ssagen.Compile(0xc0000fc2c0, 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:130 +0x65
created by cmd/compile/internal/gc.compileFunctions.func2
	/home/alberto/go/src/cmd/compile/internal/gc/compile.go:128 +0xcf

This is a 1.17 regression. Unlike #45693, the compiler crashes regardless of GOEXPERIMENT=regabiargs.

Reduced from a gosmith crasher.

cc @cherrymui @randall77 @dr2chase

@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Apr 22, 2021
@ALTree ALTree added this to the Go1.17 milestone Apr 22, 2021
@cherrymui
Copy link
Member

Before walk, we have

.   RANGE-Key
.   .   NAME-p.i tc(1) Class:PEXTERN Offset:0 Used int # p2.go:3
.   .   DEREF-init
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   NAME-p..autotmp_1 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   .   CALLFUNC tc(1) Use:1 int # p2.go:8 int
.   .   .   .   .   NAME-p.f tc(1) Class:PEXTERN Offset:0 Used FUNC-func() int # p2.go:5
.   .   DEREF tc(1) int # p2.go:8 int
.   .   .   INDEX tc(1) PTR-*int # p2.go:8 PTR-*int
.   .   .   .   NAME-p.arr tc(1) Class:PEXTERN Offset:0 Used SLICE-[]*int # p2.go:4
.   .   .   .   NAME-p..autotmp_1 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8

We set autotmp_1 before use it.

After walk,

.   FOR-Body
.   .   BLOCK # p2.go:8
.   .   BLOCK-List
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   NAME-p..autotmp_6 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used PTR-*int # p2.go:8
.   .   .   .   INDEX tc(1) PTR-*int # p2.go:8 PTR-*int
.   .   .   .   .   NAME-p.arr tc(1) Class:PEXTERN Offset:0 Used SLICE-[]*int # p2.go:4
.   .   .   .   .   NAME-p..autotmp_1 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   NAME-p..autotmp_7 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   .   INDEX tc(1) Bounded int # p2.go:8 int
.   .   .   .   .   NAME-p..autotmp_0 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used SLICE-[]int # p2.go:8
.   .   .   .   .   NAME-p..autotmp_4 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   NAME-p.i tc(1) Class:PEXTERN Offset:0 Used int # p2.go:3
.   .   .   .   NAME-p..autotmp_4 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   NAME-p..autotmp_1 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8
.   .   .   .   CALLFUNC tc(1) Use:1 Walked int # p2.go:8 int
.   .   .   .   .   NAME-p.f tc(1) Class:PEXTERN Offset:0 Used FUNC-func() int # p2.go:5
.   .   .   AS tc(1) # p2.go:8
.   .   .   .   DEREF tc(1) int # p2.go:8 int
.   .   .   .   .   NAME-p..autotmp_6 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used PTR-*int # p2.go:8
.   .   .   .   NAME-p..autotmp_7 esc(N) tc(1) Class:PAUTO Offset:0 AutoTemp OnStack Used int # p2.go:8

The set of autotmp_1 (the 4th OAS node) comes after use (the first OAS node).

@gopherbot
Copy link

Change https://golang.org/cl/312632 mentions this issue: cmd/compile: fix missing star expr in ascompatee

@ALTree
Copy link
Member Author

ALTree commented Apr 23, 2021

Possibly some cornercase was missed, this one still crashes the compiler:

package main

func main() {
	var x int
	var f func() int
	var arr []int
	var arr2 [][0]rune
	for arr[x], arr2[arr[f()]][x] = range "" {
	}
}

@ALTree ALTree reopened this Apr 23, 2021
@gopherbot
Copy link

Change https://golang.org/cl/313011 mentions this issue: cmd/compile: generalize fix for lvalue-init evaluation

@mdempsky
Copy link
Member

@ALTree Thanks for the minimized test cases.

@golang golang locked and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants