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: large ONEW with EscNone: new()" #39292

Open
AndrewWPhillips opened this issue May 28, 2020 · 4 comments
Open
Milestone

Comments

@AndrewWPhillips
Copy link

@AndrewWPhillips AndrewWPhillips commented May 28, 2020

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

$ go version
go version go1.14 windows/amd64

Also reproduced with:
go version devel +af2b592260 Wed Apr 22 14:12:34 2020 -0700 linux/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=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Andrewp\AppData\Local\go-build
set GOENV=C:\Users\Andrewp\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\Go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fmessage-length=0 -fdebug-prefix-map=L:\TEMP\go-build975958338=/tmp/go-build -gno-record-gcc-switches

What did you do?

Compiled this:

package main

type t struct {
	b [10000]int
}

func (t) f() {
}

func main() {
	x := t{}.f
	x()
}

What did you expect to see?

$ go build

$

What did you see instead?

$ go build
/D/Andrew/GoProjects/gocompilerbug
.\main.go:11:10: internal compiler error: large ONEW with EscNone: new()

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

$

@ALTree ALTree changed the title go/build: "internal compiler error: large ONEW with EscNone: new()" cmd/compile: "internal compiler error: large ONEW with EscNone: new()" May 28, 2020
@ALTree ALTree added this to the Go1.16 milestone May 28, 2020
@ALTree
Copy link
Member

@ALTree ALTree commented May 28, 2020

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 28, 2020

Interesting. Thanks for the report.

@ALTree
Copy link
Member

@ALTree ALTree commented May 28, 2020

Fails since go1.5 (go1.4 is fine). Previously a variant with a slightly different reproducer was reported in #15733 and fixed in go1.8.

@cuonglm
Copy link
Contributor

@cuonglm cuonglm commented May 28, 2020

It seems that because t{}.f does not escape, the struct generated to hold closure information is marked as does not escape, too.

When we initialized this struct fields in anylit, we generated a ONEW node with n.Esc inherits from the closure, which is EscNone.

A potential fix can be:

diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go
index f5d588e63b..e008829001 100644
--- a/src/cmd/compile/internal/gc/sinit.go
+++ b/src/cmd/compile/internal/gc/sinit.go
@@ -875,6 +875,9 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
                        r.SetTypecheck(1)
                        r.Type = t
                        r.Esc = n.Esc
+                       if mustHeapAlloc(n) {
+                               r.Esc = EscHeap
+                       }
                }

                r = walkexpr(r, init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.