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: walkConvInterface produces broken IR #56768

Closed
cuonglm opened this issue Nov 16, 2022 · 3 comments
Closed

cmd/compile: walkConvInterface produces broken IR #56768

cuonglm opened this issue Nov 16, 2022 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cuonglm
Copy link
Member

cuonglm commented Nov 16, 2022

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

$ go version
go version devel go1.20-b1678e508b Wed Nov 16 04:04:52 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env

What did you do?

Compile following program:

package p

type I interface {
	M()
}

type S struct{}

func (*S) M() {}

type slice []any

func f() {
	ss := struct {
		i I
	}{
		i: &S{},
	}

	_ = [...]struct {
		s slice
	}{
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
		{
			s: slice{ss.i},
		},
	}
}

What did you expect to see?

Compile ok.

What did you see instead?

/home/cuonglm/p.go:30:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:33:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:36:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:39:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:42:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment

The fix for #56727 reveals this bug, because it called typecheck on walked IR.

The problem is in walkConvInterface, we generate code like:

var typeWord *uint8
typeWord = itab

But itab has type *uintptr. I think we can just switch itab to *uint8 (any generic pointer type should work, I guess) cc @randall77

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 16, 2022
@cuonglm cuonglm self-assigned this Nov 16, 2022
@cuonglm cuonglm added this to the Go1.20 milestone Nov 16, 2022
@cuonglm cuonglm added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 16, 2022
@gopherbot
Copy link

Change https://go.dev/cl/451256 mentions this issue: cmd/compile: fix broken IR for iface -> eface

@cuonglm
Copy link
Member Author

cuonglm commented Nov 16, 2022

@gopherbot please backport this to go1.19

@gopherbot
Copy link

Backport issue(s) opened: #56770 (for 1.19).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@golang golang locked and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants