Skip to content

cmd/compile: Go1.22RC1 compiler crash when using GOEXPERIMENT=rangefunc #64930

@bolazec

Description

@bolazec

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

$ go version
go version devel go1.22-fe1b2f95e6 Fri Dec 8 23:05:48 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

This problem happens with go1.22rc1 when using GOEXPERIMENT=rangefunc

#61405

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

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/rafter/.cache/go-build'
GOENV='/home/rafter/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/rafter/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/rafter/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/rafter/go-compilers/go-tip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/rafter/go-compilers/go-tip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-fe1b2f95e6 Fri Dec 8 23:05:48 2023 +0000'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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-build12169918115877555041=/tmp/go-build -gno-record-gcc-switches'
GOROOT/bin/go version: go version devel go1.22-fe1b2f95e6 Fri Dec 8 23:05:48 2023 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.22-fe1b2f95e6 Fri Dec 8 23:05:48 2023 +0000
uname -sr: Linux 5.4.0-169-generic
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.14) stable release version 2.31.
gdb --version: GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2

See the program at https://go.dev/play/p/KyQscllQkMW

With GOEXPERIMENT=rangefunc this program compiles and runs correctly,
which shows that the types and functions are all OK.

However when the commented out for loop is re-enabled the program causes a compiler crash.

What did you expect to see?

No compiler crash, and a program that runs.

What did you see instead?

Compiler Output ...
# example.com/iterators/bugs/bug-1-seq2
: internal compiler error: panic: interface conversion: syntax.Type is *types2.Named, not *types2.Signature

goroutine 1 [running]:
runtime/debug.Stack()
../../../../go-compilers/go-tip/src/runtime/debug/stack.go:24 +0x5e
cmd/compile/internal/base.FatalfAt({0x44a750?, 0xc0?}, {0xdf1b09, 0x9}, {0xc00044a780, 0x1, 0x1})
../../../../go-compilers/go-tip/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/base.Fatalf(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/gc.handlePanic()
../../../../go-compilers/go-tip/src/cmd/compile/internal/gc/main.go:52 +0x90
panic({0xd72320?, 0xc000443890?})
../../../../go-compilers/go-tip/src/runtime/panic.go:770 +0x132
cmd/compile/internal/rangefunc.(*rewriter).endLoop(0xc000154400, 0xc00044e4c0)
../../../../go-compilers/go-tip/src/cmd/compile/internal/rangefunc/rewrite.go:937 +0xa3b
cmd/compile/internal/rangefunc.(*rewriter).inspect(0xc000154400, {0x0?, 0x0?})
../../../../go-compilers/go-tip/src/cmd/compile/internal/rangefunc/rewrite.go:610 +0x3f8
cmd/compile/internal/syntax.inspector.Visit(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:23
cmd/compile/internal/syntax.walker.node({{0xf5aa00?, 0xc00003b3c0?}}, {0xf5d000, 0xc0004127d0})
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:315 +0x10b8
cmd/compile/internal/syntax.walker.stmtList(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:332
cmd/compile/internal/syntax.walker.node({{0xf5aa00?, 0xc00003b3c0?}}, {0xf5c250, 0xc000414200})
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:222 +0x14f0
cmd/compile/internal/syntax.Walk(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:41
cmd/compile/internal/syntax.Inspect(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:17
cmd/compile/internal/rangefunc.rewriteFunc(0xc0003f1e00, 0xc0003f1da0, 0xc000127340, 0xc000414200)
../../../../go-compilers/go-tip/src/cmd/compile/internal/rangefunc/rewrite.go:551 +0xed
cmd/compile/internal/rangefunc.Rewrite.func1({0xf5c1c0?, 0xc0003f19e0?})
../../../../go-compilers/go-tip/src/cmd/compile/internal/rangefunc/rewrite.go:528 +0x58
cmd/compile/internal/syntax.inspector.Visit(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:23
cmd/compile/internal/syntax.walker.node({{0xf5aa00?, 0xc00040e918?}}, {0xf5c1c0, 0xc0003f19e0})
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:60 +0x8a
cmd/compile/internal/syntax.walker.declList(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:320
cmd/compile/internal/syntax.walker.node({{0xf5aa00?, 0xc00040e918?}}, {0xf5c130, 0xc0003f1980})
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:69 +0x207a
cmd/compile/internal/syntax.Walk(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:41
cmd/compile/internal/syntax.Inspect(...)
../../../../go-compilers/go-tip/src/cmd/compile/internal/syntax/walk.go:17
cmd/compile/internal/rangefunc.Rewrite(0xc0003f1e00, 0xc0003f1da0, {0xc00005c590, 0x1, 0x1?})
../../../../go-compilers/go-tip/src/cmd/compile/internal/rangefunc/rewrite.go:525 +0x5b
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0xc00005c528, 0x1, 0xf6a708?})
../../../../go-compilers/go-tip/src/cmd/compile/internal/noder/irgen.go:148 +0x956
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0xc00005c528, 0x1, 0x1})
../../../../go-compilers/go-tip/src/cmd/compile/internal/noder/unified.go:296 +0x6a
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc00005c528?, 0xd38440?, 0x0?})
../../../../go-compilers/go-tip/src/cmd/compile/internal/noder/unified.go:172 +0x9a
cmd/compile/internal/noder.LoadPackage({0xc000022230, 0x1, 0x1})
../../../../go-compilers/go-tip/src/cmd/compile/internal/noder/noder.go:77 +0x43a
cmd/compile/internal/gc.Main(0xe2ac48)
../../../../go-compilers/go-tip/src/cmd/compile/internal/gc/main.go:197 +0xbbd
main.main()
../../../../go-compilers/go-tip/src/cmd/compile/main.go:57 +0xf9

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.release-blocker

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions