Skip to content

cmd/compile: deadlock while typechecking self-referential constraint #49439

@aarzilli

Description

@aarzilli

Compiling this (wrong) code:

package main

type X[T any, PT X[T]] interface{}

causes a deadlock (I think it's trying to infer the second parameter):

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [semacquire]:
sync.runtime_SemacquireMutex(0x0?, 0xe8?, 0x29?)
	/usr/local/go/src/runtime/sema.go:71 +0x25
sync.(*Mutex).lockSlow(0xc0004140f4)
	/usr/local/go/src/sync/mutex.go:153 +0x165
sync.(*Mutex).Lock(...)
	/usr/local/go/src/sync/mutex.go:81
sync.(*Once).doSlow(0x200?, 0xc00037cb98?)
	/usr/local/go/src/sync/once.go:64 +0x53
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:59
cmd/compile/internal/types2.(*Named).resolve(0xc000414080?, 0x9e?)
	/usr/local/go/src/cmd/compile/internal/types2/named.go:44 +0x5d
cmd/compile/internal/types2.asNamed(...)
	/usr/local/go/src/cmd/compile/internal/types2/type.go:74
cmd/compile/internal/types2.under({0xe85550?, 0xc000414080?})
	/usr/local/go/src/cmd/compile/internal/types2/type.go:24 +0x56
cmd/compile/internal/types2.(*TypeParam).iface(0xc000400450)
	/usr/local/go/src/cmd/compile/internal/types2/typeparam.go:84 +0x37
cmd/compile/internal/types2.(*TypeParam).underIs(0xe85640?, 0xc000400450?)
	/usr/local/go/src/cmd/compile/internal/types2/typeparam.go:138 +0x1e
cmd/compile/internal/types2.underIs({0xe85640?, 0xc000400450?}, 0xc00037ccd0)
	/usr/local/go/src/cmd/compile/internal/types2/expr.go:165 +0x52
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions