golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.98k stars 17.67k forks source link

compiler: infinite loop and closure assertion failed #69062

Closed nikandfor closed 2 months ago

nikandfor commented 2 months ago

Go version

go version go1.23.0 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN='/Users/nik/.go/bin'
GOCACHE='/Users/nik/Library/Caches/go-build'
GOENV='/Users/nik/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/nik/.go/pkg/mod'
GONOPROXY=',***,***'
GONOSUMDB=',***,***'
GOOS='darwin'
GOPATH='/Users/nik/.go'
GOPRIVATE=',***,***'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/nik/nikandfor/jq/go.mod'
GOWORK='off'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/sh/j5dr0gmd1v50tsb0pk8yrd440000gn/T/go-build1942867075=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Made a closure.

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

package main

func main() {
        f()
}

func f() {
        back := func() {
                return
        }

back:
        for {
                back()

                continue back
        }
}

Running

$ /usr/local/go1.23/bin/go version
go version go1.23.0 darwin/arm64
$ /usr/local/go1.23/bin/go run ./closure.go # blocks here, eats 100% of a CPU core
^Csignal: interrupt

 /usr/local/go1.22/bin/go version
go version go1.22.6 darwin/arm64
$ /usr/local/go1.22/bin/go run ./closure.go # block here as well
^Csignal: interrupt

What did you see happen?

described above ^

What did you expect to see?

Expected both snippets to compile successfully with both latest go versions.

gabyhelp commented 2 months ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)