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/go: go test . results in CLOSURE ... <unknown line number>: internal compiler error: assertion failed #65593

Open
badalex opened this issue Feb 8, 2024 · 5 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@badalex
Copy link

badalex commented Feb 8, 2024

Go version

go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/alex/.cache/go-build'
GOENV='/home/alex/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/alex/go/pkg/mod'
GOOS='linux'
GOPATH='/home/alex/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/alex/bug/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-build3894783791=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Test upgrading some things to go 1.22.0, was able to cut it down to fairly small reproducer (Which also fails on the playground, yay!):

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

What did you see happen?

CLOSURE [prog_test.go:14:12:var messages chan struct{}]
: internal compiler error: assertion failed

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

What did you expect to see?

Anything other than an assertion failed

@badalex badalex changed the title go test CLOSURE ... <unknown line number>: internal compiler error: assertion failed cmd/go: go test . results in CLOSURE ... <unknown line number>: internal compiler error: assertion failed Feb 8, 2024
@cuonglm
Copy link
Member

cuonglm commented Feb 8, 2024

Simpler reproducer:

package p

const run = false

func f() {
	if !run {
		return
	}

	messages := make(chan struct{}, 1)
main:
	for range messages {
		break main
	}
}

@dr2chase dr2chase added compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 9, 2024
@dr2chase
Copy link
Contributor

dr2chase commented Feb 9, 2024

Stack trace, at tip, from the @cuonglm reproducer. Looking at who-touched-it-last and the code involved, might be related to code for the rangefunc experiment.

go tool compile p.go
CLOSURE [p.go:12:12:var messages chan struct{}]
<unknown line number>: internal compiler error: assertion failed

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/drchase/work/go/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0xd0afb78?, 0x0?}, {0xce70f54, 0x10}, {0x0, 0x0, 0x0})
	/Users/drchase/work/go/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/base.Fatalf(...)
	/Users/drchase/work/go/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/base.Assert(...)
	/Users/drchase/work/go/src/cmd/compile/internal/base/print.go:237
cmd/compile/internal/noder.assert(...)
	/Users/drchase/work/go/src/cmd/compile/internal/noder/stencil.go:15
cmd/compile/internal/noder.(*writer).funcExt(0xc00041c160, 0xc00012cd20)
	/Users/drchase/work/go/src/cmd/compile/internal/noder/writer.go:1071 +0x3a9
cmd/compile/internal/noder.(*writer).doObj(0xc00041c0b0, 0xc00041c160, {0xd0b84c0, 0xc00012cd20})
	/Users/drchase/work/go/src/cmd/compile/internal/noder/writer.go:828 +0x213
cmd/compile/internal/noder.(*pkgWriter).objIdx(0xc000002480, {0xd0b84c0, 0xc00012cd20})
	/Users/drchase/work/go/src/cmd/compile/internal/noder/writer.go:787 +0x612
cmd/compile/internal/noder.(*pkgWriter).objInstIdx(0xc000002480, {0xd0b84c0, 0xc00012cd20}, 0x0, 0x0)
	/Users/drchase/work/go/src/cmd/compile/internal/noder/writer.go:728 +0xf0
cmd/compile/internal/noder.(*writer).obj(0xc000401ce0, {0xd0b84c0?, 0xc00012cd20?}, 0xc00012cd20?)
	/Users/drchase/work/go/src/cmd/compile/internal/noder/writer.go:704 +0x2f
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0xc000062520, 0x1, 0x1})
	/Users/drchase/work/go/src/cmd/compile/internal/noder/unified.go:325 +0x53e
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc000062520?, 0xcffb180?, 0x0?})
	/Users/drchase/work/go/src/cmd/compile/internal/noder/unified.go:180 +0x9a
cmd/compile/internal/noder.LoadPackage({0xc000022050, 0x1, 0x1})
	/Users/drchase/work/go/src/cmd/compile/internal/noder/noder.go:77 +0x43a
cmd/compile/internal/gc.Main(0xd0abeb0)
	/Users/drchase/work/go/src/cmd/compile/internal/gc/main.go:197 +0xbbd
main.main()
	/Users/drchase/work/go/src/cmd/compile/main.go:57 +0xf9

@cuonglm
Copy link
Member

cuonglm commented Feb 10, 2024

@dr2chase I think the assertion is there before rangefunc added. The rangefunc code just add the dumping of closurevars.

This seems to be the issue with deadcode pass, which was moved to unified IR writer in https://go-review.googlesource.com/c/go/+/517775

cc @mdempsky

@williammartin
Copy link

williammartin commented Feb 17, 2024

We appear to be running into this with the GitHub CLI being built for windows on go 1.22. It doesn't seem to reproduce with GOOS=linux or GOOS=darwin.

@gopherbot
Copy link

Change https://go.dev/cl/565596 mentions this issue: cmd/compile: fix early deadcode with label statement

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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

7 participants