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: crash while exporting aliases (with GODEBUG=gotypesalias=1) #66550

Closed
adonovan opened this issue Mar 27, 2024 · 4 comments
Closed
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@adonovan
Copy link
Member

(using pre-go1.23 toolchain built at f6b93a4)

This input file (a test case for issue #50259) causes the compiler to crash when gotypesalias=1 is enabled:

package p

var x T[B]

type T[_ any] struct{}
type A T[B]
type B = T[A]
xtools$ GODEBUG=gotypesalias=0 go build -o x ~/w/goroot/test/typeparam/issue50259.go

(OK)

xtools$ GODEBUG=gotypesalias=1 go build -o x ~/w/goroot/test/typeparam/issue50259.go
# command-line-arguments
<unknown line number>: internal compiler error: unexpected types2.Invalid

goroutine 1 [running]:
runtime/debug.Stack()
	../goroot/src/runtime/debug/stack.go:26 +0x64
cmd/compile/internal/base.FatalfAt({0x176300?, 0x140?}, {0x104e87fa3, 0x19}, {0x0, 0x0, 0x0})
	../goroot/src/cmd/compile/internal/base/print.go:225 +0x1fc
cmd/compile/internal/base.Fatalf(...)
	../goroot/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/noder.(*pkgWriter).typIdx(0x14000176300, {0x1050c14a8, 0x1055ddd80}, 0x1400011c6e0)
	../goroot/src/cmd/compile/internal/noder/writer.go:510 +0x2f8
cmd/compile/internal/noder.(*writer).typ(0x14000414370, {0x1050c14a8?, 0x1055ddd80?})
	../goroot/src/cmd/compile/internal/noder/writer.go:470 +0x34
cmd/compile/internal/noder.(*writer).doObj(0x14000414370, 0x14000414420, {0x1050c8440, 0x14000420480})
	../goroot/src/cmd/compile/internal/noder/writer.go:844 +0x468
cmd/compile/internal/noder.(*pkgWriter).objIdx(0x14000176300, {0x1050c8440, 0x14000420480})
	../goroot/src/cmd/compile/internal/noder/writer.go:787 +0x5c0
cmd/compile/internal/noder.(*pkgWriter).objInstIdx(0x14000176300, {0x1050c8440, 0x14000420480}, 0x0, 0x0)
	../goroot/src/cmd/compile/internal/noder/writer.go:728 +0x104
cmd/compile/internal/noder.(*writer).obj(0x140004140b0, {0x1050c8440?, 0x14000420480?}, 0x14000420480?)
	../goroot/src/cmd/compile/internal/noder/writer.go:704 +0x34
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0x1400005c570, 0x1, 0x1})
	../goroot/src/cmd/compile/internal/noder/unified.go:325 +0x3bc
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0x1400005c570?, 0x10500a440?, 0x0?})
	../goroot/src/cmd/compile/internal/noder/unified.go:180 +0x98
cmd/compile/internal/noder.LoadPackage({0x14000002340, 0x1, 0x2})
	../goroot/src/cmd/compile/internal/noder/noder.go:77 +0x398
cmd/compile/internal/gc.Main(0x1050bbde0)
	../goroot/src/cmd/compile/internal/gc/main.go:197 +0xb08
main.main()
	../goroot/src/cmd/compile/main.go:57 +0x110
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 27, 2024
@cuonglm
Copy link
Member

cuonglm commented Mar 27, 2024

It seems to me this could be a bug in types2, since pkg.Scope().Lookup(name) returns an types2.Object with invalid type.

cc @griesemer

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 27, 2024
@adonovan
Copy link
Member Author

adonovan commented Mar 27, 2024

I've been working in the compiler today on alias import/export and I suspect I fixed this bug in passing. Will check.

@adonovan adonovan self-assigned this Mar 27, 2024
@mknyszek mknyszek moved this to In Progress in Go Compiler / Runtime Mar 27, 2024
@mknyszek mknyszek added this to the Go1.23 milestone Mar 27, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/574737 mentions this issue: go/types: changes to support materialized aliases

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/576139 mentions this issue: internal/gcimporter: renable tests of issue50259.go

@adonovan adonovan removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 3, 2024
gopherbot pushed a commit to golang/tools that referenced this issue Apr 4, 2024
Now that the compiler support for gotypesalias=1 is
fixed (by CL 574737), we can reenable these tests.

Updates golang/go#66550
Updates golang/go#65294

Change-Id: I70b187c561d2eeb3f7a4cc078107b7bcce5ced01
Reviewed-on: https://go-review.googlesource.com/c/tools/+/576139
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
@github-project-automation github-project-automation bot moved this from In Progress to Done in Go Compiler / Runtime Apr 5, 2024
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.
Projects
Development

No branches or pull requests

5 participants