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: internal compiler error: PtrDataSize: unexpected type, t₁ #47888

Closed
4ad opened this issue Aug 22, 2021 · 4 comments
Closed

cmd/compile: internal compiler error: PtrDataSize: unexpected type, t₁ #47888

4ad opened this issue Aug 22, 2021 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@4ad
Copy link
Member

4ad commented Aug 22, 2021

On tip(6e50991):

Related to #47887.

Repro:

package main

type Fooer[t any] interface {
	foo(Barer[t])
}
type Barer[t any] interface {
	bar(Bazer[t])
}
type Bazer[t any] interface {
	Fooer[t]
	baz(t)
}

type Int int

func (n Int) baz(int)          {}
func (n Int) foo(b Barer[int]) {}

Compiler panics with:

go build k.go
# command-line-arguments
<autogenerated>:1: internal compiler error: PtrDataSize: unexpected type, t₁

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/aram/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x8165b0, 0xc0}, {0x18ffcd3, 0x20}, {0xc000123ee0, 0x1, 0x1})
	/Users/aram/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	/Users/aram/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/types.PtrDataSize(0xc0000aa8c0)
	/Users/aram/go/src/cmd/compile/internal/types/size.go:669 +0x167
cmd/compile/internal/reflectdata.dgcsym(0xc0000aa8c0, 0xb2)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1503 +0x26
cmd/compile/internal/reflectdata.dcommontype(0xc000124078, 0xc0000aa8c0)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:692 +0xe5
cmd/compile/internal/reflectdata.writeType(0xc000414f20)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:975 +0x59c
cmd/compile/internal/reflectdata.writeType(0xc0000aa9a0)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1011 +0x12cd
cmd/compile/internal/reflectdata.writeType(0xc000414c60)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1047 +0xc5d
cmd/compile/internal/reflectdata.writeType(0xc0000aa850)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1011 +0x12cd
cmd/compile/internal/reflectdata.writeType(0xc000414b00)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1047 +0xc5d
cmd/compile/internal/reflectdata.writeType(0xc0000d2310)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1011 +0x12cd
cmd/compile/internal/reflectdata.writeType(0xc000414840)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1047 +0xc5d
cmd/compile/internal/reflectdata.writeType(0xc0000d22a0)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1011 +0x12cd
cmd/compile/internal/reflectdata.writeType(0x100cc2b)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1047 +0xc5d
cmd/compile/internal/reflectdata.writeType(0x38)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1011 +0x12cd
cmd/compile/internal/reflectdata.dextratype(0x10000003f, 0x38, 0xc0003f0230, 0x0)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:561 +0x11b
cmd/compile/internal/reflectdata.writeType(0xc0000d2000)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1142 +0x345
cmd/compile/internal/reflectdata.dcommontype(0x100cc5b, 0xc0000d2000)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:689 +0xbc
cmd/compile/internal/reflectdata.writeType(0xc0000d2000)
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:975 +0x59c
cmd/compile/internal/reflectdata.WriteRuntimeTypes()
	/Users/aram/go/src/cmd/compile/internal/reflectdata/reflect.go:1254 +0x3d8
cmd/compile/internal/gc.dumpdata()
	/Users/aram/go/src/cmd/compile/internal/gc/obj.go:118 +0x6e
cmd/compile/internal/gc.Main(0x1918b50)
	/Users/aram/go/src/cmd/compile/internal/gc/main.go:320 +0x10c5
main.main()
	/Users/aram/go/src/cmd/compile/main.go:55 +0xdd
@4ad 4ad added this to the Go1.18 milestone Aug 22, 2021
@griesemer griesemer added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 22, 2021
@griesemer
Copy link
Contributor

@danscales This looks like a node translation issue. The code type-checks and compiles without error with unified IR.

@danscales
Copy link
Contributor

OK, I think this is similar to issue #47710 - we need an adjustment to the types2-to-types1 translation when there is mutual recursion of types via their methods. I'll work on them together and make sure they are both fixed by the change I make.

@danscales
Copy link
Contributor

OK, looks like this actually waits for the fix to #47887 - the type Barer[int] that we get from types2 is not fully instantiated - underneath, it contains a type Fooer[int] whose method contains a type param (rather than having the 'int' that should be there). I'll recheck once #47887 is fixed.

@danscales
Copy link
Contributor

As Robert points out in #47887, this is now fixed for the compiler as well (i.e. it was only a types2 issue).

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

4 participants