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: 'init': value .dict (nil) incorrectly live at entry #57778

Closed
dveeden opened this issue Jan 13, 2023 · 9 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@dveeden
Copy link

dveeden commented Jan 13, 2023

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

$ go1.20rc3 version
go version go1.20rc3 linux/amd64

Does this issue reproduce with the latest release?

Happens with 1.20rc3 and not with 1.19.4

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

go env Output
$ go1.20rc3 env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dvaneeden/.cache/go-build"
GOENV="/home/dvaneeden/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dvaneeden/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dvaneeden/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/dvaneeden/sdk/go1.20rc3"
GOSUMDB="sum.golang.org"
GOTMPDIR="/home/dvaneeden/go/tmp"
GOTOOLDIR="/home/dvaneeden/sdk/go1.20rc3/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20rc3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/foo/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/home/dvaneeden/go/tmp/go-build3602575493=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This happens for https://pkg.go.dev/github.com/google/btree that's used in https://github.com/pingcap/tiflow

To reproduce:

package main

type FreeListG[T any] struct {
	freelist []*node[T]
}

type node[T any] struct {
}

func NewFreeListG[T any](size int) *FreeListG[T] {
	return &FreeListG[T]{freelist: make([]*node[T], 0, size)}
}

var (
	bf = NewFreeListG[*int](1024)
)

func main() {

}

Or with external dependencies:

package main

import "github.com/google/btree"

var (
	bf = btree.NewFreeListG[*int](1024)
)

func main() {

}

What did you expect to see?

$ go version 
go version go1.19.4 linux/amd64
$ go build foo.go
$

What did you see instead?

$ go1.20rc3 build foo.go 
# command-line-arguments
./foo.go:15:2: internal compiler error: 'init': value .dict (nil) incorrectly live at entry

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

compile ok with go build -gcflags=-d=inlstaticinit=1 or GOEXPERIMENT=nounified go build.

@seankhliao seankhliao changed the title compiler: internal compiler error: 'init': value .dict (nil) incorrectly live at entry cmd/compile: internal compiler error: 'init': value .dict (nil) incorrectly live at entry Jan 13, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 13, 2023
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 13, 2023
@seankhliao
Copy link
Member

cc @golang/compiler

@wdvxdr1123
Copy link
Contributor

another repro:

package main

type M[T comparable] struct {
	m map[T]int
}

func NewM[T comparable](x T) *M[T] {
	return &M[T]{m: map[T]int{x: 1}}
}

var foo = NewM[int](1)

func main() {

}

@gopherbot
Copy link

Change https://go.dev/cl/461756 mentions this issue: cmd/compile: fix static init for generic inlined calls

@bcmills bcmills added this to the Go1.20 milestone Jan 13, 2023
@gopherbot
Copy link

Change https://go.dev/cl/461757 mentions this issue: cmd/compile: disable static init inline for node that needs rtype

@thepudds
Copy link
Contributor

thepudds commented Jan 17, 2023

In case useful, another example using tip as of this morning. (Seen while testing #57173 on many public modules).

git clone -b v1.5.14 https://github.com/mpetavy/common
cd common
go build ./...

Error:

# github.com/mpetavy/common
./app.go:92:2: internal compiler error: 'init': value .dict (nil) incorrectly live at entry

Version:

go version devel go1.20-66689c7 Tue Jan 17 15:26:07 2023 +0000 linux/amd64

@randall77
Copy link
Contributor

@mdempsky

@mdempsky mdempsky self-assigned this Jan 17, 2023
@gopherbot
Copy link

Change https://go.dev/cl/461686 mentions this issue: cmd/compile: disable static init inlining for hidden node fields

@gopherbot
Copy link

Change https://go.dev/cl/462535 mentions this issue: cmd/compile: fix static init inlining for hidden node fields

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 17, 2023
gopherbot pushed a commit that referenced this issue Jan 17, 2023
…den node fields

Unified IR added several new IR fields for holding *runtime._type
expressions. To avoid throwing off any frontend semantics
(particularly inlining cost heuristics), they were marked as
`mknode:"-"` so that code wouldn't visit them.

Unfortunately, this has a bad interaction with the static init
inlining optimization, because the latter relies on ir.EditChildren to
substitute all parameters. This potentially includes dictionary
parameters, which can appear within the new RType fields.

This CL adds a new ir.EditChildrenWithHidden function that also edits
these fields, and switches staticinit to use it. Longer term, we
should unhide the RType fields so that ir.EditChildren visits them
normally, but that's scarier so late in the release cycle.

Updates #57778.
Updates #57854.

Change-Id: I98c1e8cf366156dc0c81a0cb79029cc5e59c476f
Reviewed-on: https://go-review.googlesource.com/c/go/+/461686
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 9f2fbedf010d59c3ecaa8c25b07a5f68fcb2e3d5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/462535
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Jan 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

9 participants