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: 'foo.toStrings': value v2 still has 1 uses #68585

Closed
PPYSC opened this issue Jul 25, 2024 · 6 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. gabywins NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@PPYSC
Copy link

PPYSC commented Jul 25, 2024

Go version

go version go1.22.5 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/bigdata/qiuhan/go1.22.5'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/bigdata/qiuhan/go1.22.5/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='/usr/bin/gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/bigdata/qiuhan/difftest/20240725_test_unit/d_2055/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 -ffile-prefix-map=/tmp/go-build389564710=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Compile using the command go build main.go.

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

package main

type Stringer interface {
	String() string
}

type (
	stringer  struct{}
	stringers [2]stringer
	foo       struct {
		stringers
	}
)

func (stringer) String() string  { return "" }
func toString(s Stringer) string { return s.String() }

func (v stringers) toStrings() []string {
	return []string{toString(v[0]), toString(v[1])}
}

func main() {
	_ = stringers{}
}

What did you see happen?

An internal compiler error occurred.

$ go build main.go
# 2055
<autogenerated>:1: internal compiler error: 'foo.toStrings': value v2 still has 1 uses

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

What did you expect to see?

Successful compilation of the program.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 25, 2024
@cuonglm
Copy link
Member

cuonglm commented Jul 25, 2024

Likely duplicated of #65808

@randall77
Copy link
Contributor

Does that mean the fix for #65808 needs to be backported to 1.22?
@dr2chase

@dr2chase
Copy link
Contributor

I just checked, it applies clean, and the test passes. And the fix itself is very low risk.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/601195 mentions this issue: [release-branch.go1.22] cmd/compile: add 0-sized-value simplification to copyelim

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 26, 2024
gopherbot pushed a commit that referenced this issue Jul 31, 2024
… to copyelim

The problem was caused by faulty handling of unSSA-able
operations on zero-sized data in expand calls, but there
is no point to operations on zero-sized data.  This CL adds
a simplify step to the first place in SSA where all values
are processed and replaces anything producing a 0-sized
struct/array with the corresponding Struct/Array Make0
operation (of the appropriate type).

I attempted not generating them in ssagen, but that was a
larger change, and also had bugs. This is simple and obvious.
The only question is whether it would be worthwhile to do it
earlier (in numberlines or phielem).

Fixes #68594.
Fixes #68585.

Change-Id: I0a596b3d272798015e7bb6b1a20411241759fe0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/568258
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 6f5d774)
Reviewed-on: https://go-review.googlesource.com/c/go/+/601195
@dmitshur dmitshur added this to the Go1.23 milestone Jul 31, 2024
@dmitshur
Copy link
Contributor

Closing as duplicate of #65808.

@dmitshur dmitshur closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. gabywins NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

8 participants