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: ICE on slice of array pointer returned by a generic function #71184

Open
mcy opened this issue Jan 8, 2025 · 2 comments
Open

cmd/compile: ICE on slice of array pointer returned by a generic function #71184

mcy opened this issue Jan 8, 2025 · 2 comments
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.

Comments

@mcy
Copy link

mcy commented Jan 8, 2025

Go version

go version go1.23.0 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mcyoung/Library/Caches/go-build'
GOENV='/Users/mcyoung/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mcyoung/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mcyoung/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/mcyoung/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/mcyoung/code/protocompile/go.mod'
GOWORK='/Users/mcyoung/code/protocompile/go.work'
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/5l/2_ns6hbx1gj92vv9pkrl_jdc0000gn/T/go-build656695524=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

The following program crashes the compiler:

package x

func F[T int32]() {
	_ = G[*[0]T]()[:]
}

func G[T any]() (v T) {
	return
}

var _ = F[int32]

I have not been able to reduce this program further: everything, except the body of G, is essential to triggering the bug. F must be stenciled, G must return a generic type, not *T or *[0]T, and the type constraint on F[T] seems to be irrelevant.

What did you see happen?

ICE.

./prog.go:3:6: internal compiler error: 'F[int32]': bad ptr to array in slice go.shape.*uint8


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

What did you expect to see?

Not an ICE.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 8, 2025
@mauri870
Copy link
Member

mauri870 commented Jan 8, 2025

In gotip I get a more verbose error:

# command-line-arguments
./test.go:3:6: internal compiler error: 'F[int32]': bad ptr to array in slice go.shape.*uint8


./test.go:4:16: internal compiler error: 'F[go.shape.int32]': bad ptr to array in slice go.shape.*uint8


goroutine 9 [running]:
runtime/debug.Stack()
        ./src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x47aea0?, 0xc0?}, {0xc000027320, 0x23}, {0xc00046c360, 0x2, 0x2})
        ./src/cmd/compile/internal/base/print.go:230 +0x1ea
cmd/compile/internal/base.Fatalf(...)
        ./src/cmd/compile/internal/base/print.go:195
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x0?, {0x46e260?, 0xc0?}, {0xec7884, 0x1d}, {0xc00046e260, 0x1, 0x1?})
        ./src/cmd/compile/internal/ssagen/ssa.go:7341 +0x171
cmd/compile/internal/ssagen.(*state).Fatalf(0xc00045c8f0?, {0xec7884?, 0xc000040a00?}, {0xc00046e260?, 0xc0004661a0?, 0x0?})
        ./src/cmd/compile/internal/ssagen/ssa.go:965 +0x64
cmd/compile/internal/ssagen.(*state).slice(0xc000040a00, 0xc000568c70, 0x0, 0x0, 0x0, 0x0)
        ./src/cmd/compile/internal/ssagen/ssa.go:5194 +0x35a
cmd/compile/internal/ssagen.(*state).exprCheckPtr(0xc000040a00, {0x1037310, 0xc000465600}, 0x1)
        ./src/cmd/compile/internal/ssagen/ssa.go:3411 +0x564e
cmd/compile/internal/ssagen.(*state).expr(...)
        ./src/cmd/compile/internal/ssagen/ssa.go:2783
cmd/compile/internal/ssagen.(*state).stmt(0xc000040a00, {0x1037a18, 0xc000462780})
        ./src/cmd/compile/internal/ssagen/ssa.go:1682 +0x7065
cmd/compile/internal/ssagen.(*state).stmtList(...)
        ./src/cmd/compile/internal/ssagen/ssa.go:1449
cmd/compile/internal/ssagen.buildssa(0xc00043da40, 0x3, 0x0)
        ./src/cmd/compile/internal/ssagen/ssa.go:580 +0x2aa5
cmd/compile/internal/ssagen.Compile(0xc00043da40, 0x3, 0xc00009c788?)
        ./src/cmd/compile/internal/ssagen/pgen.go:304 +0x88
cmd/compile/internal/gc.compileFunctions.func5.1(0x455232?)
        ./src/cmd/compile/internal/gc/compile.go:189 +0x38
cmd/compile/internal/gc.compileFunctions.func3.1()
        ./src/cmd/compile/internal/gc/compile.go:171 +0x30
created by cmd/compile/internal/gc.compileFunctions.func3 in goroutine 8
        ./src/cmd/compile/internal/gc/compile.go:170 +0x247

cc @randall77

@prattmic
Copy link
Member

prattmic commented Jan 9, 2025

cc @golang/compiler

@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 9, 2025
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
Status: No status
Development

No branches or pull requests

4 participants