-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
cmd/compile: internal compiler error: assertion failed #53762
Comments
Can you share a copy of the code that you are compiling? Thanks. |
I am sharing two files here (had to change the suffix to upload), but I couldn't come up with a minimal example just using |
Here is a small repro package main
type Value[T any] interface {
}
func use[T any](v Value[T]) {
_, _ = v.(int)
}
func main() {
use(Value[int](nil))
} |
Change https://go.dev/cl/416736 mentions this issue: |
I can reproduce on go 1.18.4. |
Backport issue(s) opened: #53274 (for 1.18). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Thanks for your efforts. I just tried to compile with the latest gotip. % gotip version go version devel go1.19-c006b7ac27 Wed Jul 13 18:35:00 2022 +0000 darwin/amd64 Unfortunately, the original problem persists. /Users/Clemens/Programs/Go/comp/sum.go:33:19: internal compiler error: assertion failed goroutine 1 [running]: runtime/debug.Stack() /Users/Clemens/sdk/gotip/src/runtime/debug/stack.go:24 +0x65 cmd/compile/internal/base.FatalfAt({0x16b0af8?, 0xc0?}, {0x193fdeb, 0x10}, {0x0, 0x0, 0x0}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/base/print.go:227 +0x1d7 cmd/compile/internal/base.Fatalf(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/base/print.go:196 cmd/compile/internal/base.Assert(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/base/print.go:239 cmd/compile/internal/noder.assert(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:27 cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1aacd08, 0xc0016c14a0}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1367 +0x2bb cmd/compile/internal/ir.editNodes(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1388 cmd/compile/internal/ir.(*AssignListStmt).editChildren(0xc0016bcf00, 0xc000e96cc0) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:85 +0xc2 cmd/compile/internal/ir.EditChildren(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185 cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1aaaa88, 0xc0016bcf00}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1256 +0x11b cmd/compile/internal/ir.editNodes(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/node_gen.go:1388 cmd/compile/internal/ir.(*Func).editChildren(0xc000ba14f0?, 0xc000e96cc0?) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/func.go:152 +0x74 cmd/compile/internal/ir.EditChildren(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/ir/visit.go:185 cmd/compile/internal/noder.(*genInst).dictPass.func1({0x1aab778, 0xc0013f5680}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1256 +0x11b cmd/compile/internal/noder.(*genInst).dictPass(0x1fccb20, 0xc0016b0af8) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:1426 +0x150 cmd/compile/internal/noder.(*genInst).buildInstantiations(0x1fccb20) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:78 +0x1cc cmd/compile/internal/noder.BuildInstantiations(...) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/stencil.go:44 cmd/compile/internal/noder.(*irgen).generate(0xc0001f0240, {0xc0001a8780, 0x14, 0x200f780?}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:333 +0x3d1 cmd/compile/internal/noder.check2({0xc0001a8780, 0x14, 0x14}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/irgen.go:87 +0x14d cmd/compile/internal/noder.LoadPackage({0xc00019c100, 0x14, 0x14}) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/noder/noder.go:82 +0x48f cmd/compile/internal/gc.Main(0x1968268) /Users/Clemens/sdk/gotip/src/cmd/compile/internal/gc/main.go:189 +0xbbd main.main() /Users/Clemens/sdk/gotip/src/cmd/compile/main.go:57 +0xdd Will you re-open this issue or should I create a new one? |
I did some more testing:
I hope this helps to bisect the change. |
@Clemens-H can you share more code? I cannot reproduce with your code. |
Yes, as I mentioned above, the two functions I posted are referenced as the source position, but these two functions by themselves are not enough to trigger the error. I have been trying to come up with a minimal example, but for now the remaining program is still quite large. The smallest example I have is this: I can import The compiler error is due to the assertion in line 1367 in |
Can this issue be re-opened? I believe tip is still broken and fails to compile some code with generics. #54135 has a small standalone repro for this issue. |
Good news:
|
For type assertions, if src type is empty interface, we should use normal type assertions rather than dynamic type assertions. Fixes golang#53762 Change-Id: I596b2e4ad647fe5e42ad884f7273c78f8f50dac2 Reviewed-on: https://go-review.googlesource.com/c/go/+/416736 Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Bad news:
|
please file new, proper bug reports. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No, it works fine with 1.18.3.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to compile some generics heavy code.
What did you expect to see?
A working program.
What did you see instead?
An internal compiler error.
I could not identify a small example using the referenced location.
I attach three traces here.
The text was updated successfully, but these errors were encountered: