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. #52673

Closed
ddaa2000 opened this issue May 3, 2022 · 16 comments
Closed
Labels
NeedsFix release-blocker
Milestone

Comments

@ddaa2000
Copy link

@ddaa2000 ddaa2000 commented May 3, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18.1 windows/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=      
set GOCACHE=C:\Users\ddaa\AppData\Local\go-build
set GOENV=C:\Users\ddaa\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\ddaa\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\ddaa\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\programing\go\bugReview\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ddaa\AppData\Local\Temp\go-build1175442941=/tmp/go-build -gno-rec
ord-gcc-switches

What did you do?

https://go.dev/play/p/sgQ1Oc01pz2

What did you expect to see?

compile successfully

What did you see instead?

./prog.go:9:6: internal compiler error: 'main': Value live at entry. It shouldn't be. func main, node .autotmp_5, value v118

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new

Go build failed.
@seankhliao seankhliao changed the title affected/package: cmd/compiler internal compiler error cmd/compile: internal compiler error May 3, 2022
@dr2chase dr2chase added the NeedsInvestigation label May 3, 2022
@dr2chase
Copy link
Contributor

@dr2chase dr2chase commented May 3, 2022

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 3, 2022

Closing on the assumption that this is a dup of #52590. Thanks for reporting it.

@cuonglm
Copy link
Member

@cuonglm cuonglm commented May 3, 2022

@ianlancetaylor This is different bug involve initialization of composite literal.

@cuonglm cuonglm reopened this May 3, 2022
@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 3, 2022

Yeah, #52590 was an exporter issue, but this issue is reproducible with a single source file (i.e., no export involved).

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented May 3, 2022

Ah, sorry.

@ianlancetaylor ianlancetaylor changed the title cmd/compile: internal compiler error cmd/compile: internal compiler error: Value live at entry. It shouldn't be. May 3, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone May 3, 2022
@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 3, 2022

FWIW, the issue repros in Go 1.17 too, after removing generics: https://go.dev/play/p/3iLxskmJgIS?v=goprev

Edit: Simpler: https://go.dev/play/p/UU1h7nOwoyY?v=goprev

@cuonglm
Copy link
Member

@cuonglm cuonglm commented May 3, 2022

@mdempsky Seems the bug was introduced when the compiler was changed to handle array literal with more than 4 elements. This program:

package p

type b bool

func f() {
	func() [10][]bool {
		return [10][]bool{
			[]bool{bool(g(false) < "")},
			[]bool{}, []bool{}, []bool{}, []bool{}}
	}()
}

func g(b) (s string) { return }

compile ok with go1.4 😃

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 3, 2022

@cuonglm Thanks. Do you want to take this issue?

@cuonglm
Copy link
Member

@cuonglm cuonglm commented May 3, 2022

@cuonglm Thanks. Do you want to take this issue?

Yes, no problem!

@cuonglm
Copy link
Member

@cuonglm cuonglm commented May 4, 2022

@mdempsky So for code like:

package p

func f() {
	var x string
	func() [10][]bool {
		return [10][]bool{
			[]bool{bool(x < "")},
			[]bool{}, []bool{}, []bool{}, []bool{}}
	}()
}

We initialize the code roughly as:

.stmp_1[0] = len(x) < 0
~R0 = .stmp_0

Then call to fixedlit at L573 (cmd/compile/internal/walk/complit.go) rewrites it to:

.stmp_1[0] = .autotmp_4 < 0
~R0 = .stmp_0
autotmp_3 = <nil>
autotmp_2 = &.autotmp_3
.autotmp_4 = len(x)
.autotmp_2[0] = .autotmp_4 < 0
<node VARKILL>

I have no ideal how to fix it yet.

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 4, 2022

@cuonglm Okay, I can take a look tomorrow. Thanks for investigating!

@cuonglm
Copy link
Member

@cuonglm cuonglm commented May 4, 2022

@cuonglm Okay, I can take a look tomorrow. Thanks for investigating!

Don't mind, I think I figured it out!

@gopherbot
Copy link

@gopherbot gopherbot commented May 4, 2022

Change https://go.dev/cl/403995 mentions this issue: cmd/compile: fix static init of literal contains dynamic exprs

@dmitshur dmitshur added NeedsFix and removed NeedsInvestigation labels May 4, 2022
@dr2chase
Copy link
Contributor

@dr2chase dr2chase commented May 4, 2022

@dmitshur did we want to push for a backport for this one, or does it not make the train for next week?

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 4, 2022

This isn't a Go 1.18 regression. I don't think it needs to be backported.

@randall77
Copy link
Contributor

@randall77 randall77 commented May 4, 2022

Generally ICEs that are triggered only by fuzzing the compiler don't need backporting.
If it generated bad code, then maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix release-blocker
Projects
None yet
Development

No branches or pull requests

8 participants