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: "bad ptr to array in slice" in SSA slice handling #71252

Open
prattmic opened this issue Jan 13, 2025 · 1 comment
Open

cmd/compile: "bad ptr to array in slice" in SSA slice handling #71252

prattmic opened this issue Jan 13, 2025 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. compiler/telemetry-wins NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@prattmic
Copy link
Member

#!stacks
"cmd/compile/internal/ssagen.(*state).slice:+14"

Issue created by stacks.

This stack XSjlkw was reported by telemetry:

cmd/compile@go1.23.2 go1.23.2 linux/amd64 (8)

https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/cmd/compile/internal/ssagen/ssa.go;l=6151;drc=a130fb63091bf3103bb7baabbd2484f7e560edae

func (s *state) slice(v, i, j, k *ssa.Value, bounded bool) (p, l, c *ssa.Value) {
	t := v.Type
	var ptr, len, cap *ssa.Value
	switch {
...
	case t.IsPtr():
		if !t.Elem().IsArray() {
			s.Fatalf("bad ptr to array in slice %v\n", t)
		}

cc @golang/compiler

@prattmic prattmic added compiler/runtime Issues related to the Go compiler and/or runtime. compiler/telemetry-wins NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jan 13, 2025
@prattmic prattmic added this to the Backlog milestone Jan 13, 2025
@randall77
Copy link
Contributor

Not sure how this could happen. We're trying to compile the slice of a pointer, but it isn't a pointer to an array.
I don't think the frontend should let such code through - it should fail typecheck.
Possibly this is something that could be triggered with generics? Maybe the right underlying types setup would let it happen? I tried a bunch of combinations but either the frontend reported a typecheck error or the backend compiled successfully.

@griesemer

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

No branches or pull requests

2 participants