Skip to content

cmd/compile: deadlock importing generic alias in recursive struct field #78343

@jake-ciolek

Description

@jake-ciolek

Go version

go 1.26.1 + tip

Output of go env in your module/workspace:

GOARCH=arm64

What did you do?

// p/p.go
package p

type A[T any] = *B[T]

type B[T any] struct {
	C A[T]
}
// main.go
package main

import "m/p"

type C p.B[int]

func main() {}

Run go build on the above.

What did you see happen?

$ go build .                                                                                                                                                                             
# m
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [sync.Mutex.Lock]:
internal/sync.runtime_SemacquireMutex(0x5bddf45355d8?, 0x9c?, 0x5bddf45355a8?)
	runtime/sema.go:95 +0x28
internal/sync.(*Mutex).lockSlow(0x5bddf46427a0)
	internal/sync/mutex.go:149 +0x170
internal/sync.(*Mutex).Lock(...)
	internal/sync/mutex.go:70
sync.(*Mutex).Lock(...)
	sync/mutex.go:46
cmd/compile/internal/types2.(*Named).unpack(0x5bddf4642780)
	cmd/compile/internal/types2/named.go:229 +0x98
cmd/compile/internal/types2.(*Named).TypeParams(...)
	cmd/compile/internal/types2/named.go:390
cmd/compile/internal/types2.(*subster).typ(0x5bddf4535cc0, {0x101f940e8, 0x5bddf4642800})
	cmd/compile/internal/types2/subst.go:245 +0x3d8
cmd/compile/internal/types2.(*subster).typ(0x5bddf4535cc0, {0x101f94098, 0x5bddf4533490})
	cmd/compile/internal/types2/subst.go:140 +0x168

What did you expect to see?

No deadlock.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions