-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go version devel go1.23-105ac94486 Fri May 17 21:53:50 2024 +0000 darwin/arm64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/a/Library/Caches/go-build'
GOENV='/Users/a/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/a/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/a/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/a/proj/goroot'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/a/proj/goroot/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='devel go1.23-105ac94486 Fri May 17 21:53:50 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/a/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/a/Downloads/coro/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/9c/t7b8z6m93sxgr4m4m4kbvllw0000gn/T/go-build3075036886=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
Run a minimized variant of closed #65946,
-- go.mod --
module blah.com
go 1.22
-- main.go --
package main
/*
void c_callbacks(void) {
}
*/
import "C"
var iterator = func(yield func(struct{}) bool) {
}
func main() {
for _ = range iterator {
}
}
Results in an internal compiler error.
What did you see happen?
# blah.com
<unknown line number>: internal compiler error: panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
runtime/debug.Stack()
../../proj/goroot/src/runtime/debug/stack.go:26 +0x64
cmd/compile/internal/base.FatalfAt({0x35e78?, 0x140?}, {0x10380d771, 0x9}, {0x14000035ea8, 0x1, 0x1})
../../proj/goroot/src/cmd/compile/internal/base/print.go:230 +0x20c
cmd/compile/internal/base.Fatalf(...)
../../proj/goroot/src/cmd/compile/internal/base/print.go:195
cmd/compile/internal/gc.handlePanic()
../../proj/goroot/src/cmd/compile/internal/gc/main.go:53 +0x8c
panic({0x103a57540?, 0x10412d0d0?})
../../proj/goroot/src/runtime/panic.go:760 +0x124
cmd/compile/internal/types2.(*Checker).handleBailout(0x1400008a700, 0x14000037158)
../../proj/goroot/src/cmd/compile/internal/types2/check.go:390 +0x9c
panic({0x103a57540?, 0x10412d0d0?})
../../proj/goroot/src/runtime/panic.go:760 +0x124
cmd/compile/internal/noder.checkFiles.func1({0x103b0c780?, 0x1400068bb80?})
../../proj/goroot/src/cmd/compile/internal/noder/irgen.go:78 +0x1b0
cmd/compile/internal/types2.(*Checker).handleError(0x1400008a700, 0x0, {0x140000a0030?, 0xbc370?, 0x140?}, 0x6d, {0x140000c8310, 0x67}, 0x1)
../../proj/goroot/src/cmd/compile/internal/types2/errors.go:206 +0x304
cmd/compile/internal/types2.(*error_).report(0x140000363d8)
../../proj/goroot/src/cmd/compile/internal/types2/errors.go:147 +0x1f4
cmd/compile/internal/types2.(*Checker).softErrorf(0x103821eaf?, {0x103b0ca80?, 0x1400068bb00?}, 0x103b136c0?, {0x103821e7f?, 0x10414f1a0?}, {0x140000365f8?, 0x0?, 0x14000036718?})
../../proj/goroot/src/cmd/compile/internal/types2/errors.go:235 +0x70
cmd/compile/internal/types2.(*Checker).rangeStmt(0x1400008a700, 0x3, 0x140000bc2d0, 0xffffffffffffffff?)
../../proj/goroot/src/cmd/compile/internal/types2/stmt.go:865 +0x3dc
cmd/compile/internal/types2.(*Checker).stmt(0x1400008a700, 0x0, {0x103b112b0, 0x140000bc2d0})
../../proj/goroot/src/cmd/compile/internal/types2/stmt.go:642 +0x43c
cmd/compile/internal/types2.(*Checker).stmtList(...)
../../proj/goroot/src/cmd/compile/internal/types2/stmt.go:120
cmd/compile/internal/types2.(*Checker).funcBody(0x1400008a700, 0x140000c2070?, {0x140000ba034?, 0x14000480000?}, 0x1400068ba40, 0x140000be100, {0x0?, 0x0?})
../../proj/goroot/src/cmd/compile/internal/types2/stmt.go:40 +0x268
cmd/compile/internal/types2.(*Checker).funcDecl.func1()
../../proj/goroot/src/cmd/compile/internal/types2/decl.go:784 +0x44
cmd/compile/internal/types2.(*Checker).processDelayed(...)
../../proj/goroot/src/cmd/compile/internal/types2/check.go:502
cmd/compile/internal/types2.(*Checker).checkFiles(0x1400008a700, {0x140000b2048, 0x3, 0x3})
../../proj/goroot/src/cmd/compile/internal/types2/check.go:448 +0x6ec
cmd/compile/internal/types2.(*Checker).Files(0x16cfc746f?, {0x140000b2048?, 0x0?, 0x0?})
../../proj/goroot/src/cmd/compile/internal/types2/check.go:408 +0x80
cmd/compile/internal/types2.(*Config).Check(0x140000c21c0, {0x16cfc746f?, 0x14000010087?}, {0x140000b2048, 0x3, 0x3}, 0x140000961e0)
../../proj/goroot/src/cmd/compile/internal/types2/api.go:480 +0x68
cmd/compile/internal/noder.checkFiles({0x0, {0x0, 0x0}}, {0x140001fe768, 0x3, 0x14000078960?})
../../proj/goroot/src/cmd/compile/internal/noder/irgen.go:89 +0x4ac
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0x140001fe768, 0x3, 0x3})
../../proj/goroot/src/cmd/compile/internal/noder/unified.go:307 +0x48
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x140001fe768?, 0x103a08f60?, 0x0?})
../../proj/goroot/src/cmd/compile/internal/noder/unified.go:183 +0x98
cmd/compile/internal/noder.LoadPackage({0x140000204d0, 0x3, 0x3})
../../proj/goroot/src/cmd/compile/internal/noder/noder.go:77 +0x398
cmd/compile/internal/gc.Main(0x103b06ba0)
../../proj/goroot/src/cmd/compile/internal/gc/main.go:200 +0xb40
main.main()
../../proj/goroot/src/cmd/compile/main.go:57 +0x110
What did you expect to see?
Removing the Cgo use replaces the ICE with a proper error:
# blah.com
./main.go:7:16: cannot range over iterator (variable of type func(yield func(struct{}) bool)): requires go1.23 or later (-lang was set to go1.22; check go.mod)
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.