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: dictionary variable not captured by value #52907

Closed
ALTree opened this issue May 14, 2022 · 5 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented May 14, 2022

$ gotip version
go version devel go1.19-3474cd4eee Sat May 14 04:25:13 2022 +0000 linux/amd64
package main

func f[T int](t T) {
	for true {
		func() {
			t = func() T { return t }()
		}()
	}
}

func main() {
	f(0)
}
$ gotip build crash.go
# command-line-arguments
./crash.go:7:4: internal compiler error: dictionary variable not captured by value

goroutine 1 [running]:
runtime/debug.Stack()
	./gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x412fc0?, 0xc0?}, {0xd540b1, 0x29}, {0x0, 0x0, 0x0})
	./gotip/src/cmd/compile/internal/base/print.go:227 +0x1d7
cmd/compile/internal/escape.(*batch).flowClosure(0xc000172fc0?, {0xc0004132d0?, 0x1?, 0x0?, 0x48?}, 0x0?)
	./gotip/src/cmd/compile/internal/escape/escape.go:251 +0x2d6
cmd/compile/internal/escape.Batch({0xc0004008c8?, 0x2, 0x3}, 0x0?)
	./gotip/src/cmd/compile/internal/escape/escape.go:153 +0x3ce
cmd/compile/internal/ir.(*bottomUpVisitor).visit(0xc00041e2a0, 0xc00040a3c0)
	./gotip/src/cmd/compile/internal/ir/scc.go:127 +0x303
cmd/compile/internal/ir.(*bottomUpVisitor).visit.func1({0xea91f8?, 0xc00040a3c0?})
	./gotip/src/cmd/compile/internal/ir/scc.go:81 +0x45
cmd/compile/internal/ir.(*bottomUpVisitor).visit.func2({0xea9c08, 0xc0003fb970})
	./gotip/src/cmd/compile/internal/ir/scc.go:91 +0x7e
cmd/compile/internal/ir.Visit.func1({0xea9c08, 0xc0003fb970})
	./gotip/src/cmd/compile/internal/ir/visit.go:105 +0x30
cmd/compile/internal/ir.(*CallExpr).doChildren(0xc000170360, 0xc0004201e0)
	./gotip/src/cmd/compile/internal/ir/node_gen.go:237 +0x56
cmd/compile/internal/ir.DoChildren(...)
	./gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0xea8a10, 0xc000170360})
	./gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.doNodes(...)
	./gotip/src/cmd/compile/internal/ir/node_gen.go:1373
cmd/compile/internal/ir.(*Func).doChildren(0xea91f8?, 0xc0004201e0?)
	./gotip/src/cmd/compile/internal/ir/func.go:151 +0x6e
cmd/compile/internal/ir.DoChildren(...)
	./gotip/src/cmd/compile/internal/ir/visit.go:94
cmd/compile/internal/ir.Visit.func1({0xea91f8, 0xc00040a000})
	./gotip/src/cmd/compile/internal/ir/visit.go:106 +0x57
cmd/compile/internal/ir.Visit({0xea91f8, 0xc00040a000}, 0xc00005f370)
	./gotip/src/cmd/compile/internal/ir/visit.go:108 +0xb8
cmd/compile/internal/ir.(*bottomUpVisitor).visit(0xc00041e2a0, 0xc00040a000)
	./gotip/src/cmd/compile/internal/ir/scc.go:87 +0x1d5
cmd/compile/internal/ir.VisitFuncsBottomUp({0xc000130400, 0x5, 0x2?}, 0xd668f0)
	./gotip/src/cmd/compile/internal/ir/scc.go:60 +0x108
cmd/compile/internal/escape.Funcs(...)
	./gotip/src/cmd/compile/internal/escape/escape.go:119
cmd/compile/internal/gc.Main(0xd667d0)
	./gotip/src/cmd/compile/internal/gc/main.go:268 +0xdf7
main.main()
	./gotip/src/cmd/compile/main.go:57 +0xdd

cc @mdempsky @cuonglm

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 14, 2022
@ALTree ALTree added this to the Go1.19 milestone May 14, 2022
@cuonglm cuonglm self-assigned this May 14, 2022
@cuonglm cuonglm added NeedsFix The path to resolution is known, but the work has not been done. release-blocker and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 14, 2022
@gopherbot
Copy link

Change https://go.dev/cl/406176 mentions this issue: cmd/compile: fix inlining function has shape in type

@ALTree
Copy link
Member Author

ALTree commented May 14, 2022

package main

func f[T int](g T) {
	for true {
		_ = func() T { return func(int) T { return g }(0) }()
	}
}

func main() {
	f(0)
}

This slightly different reproducer triggers a compiler crash for me after the CL above.

@cuonglm cuonglm reopened this May 15, 2022
@gopherbot
Copy link

Change https://go.dev/cl/406475 mentions this issue: cmd/compile: tighten the condition for inlining shape/non-shape function

@cuonglm
Copy link
Member

cuonglm commented May 15, 2022

@ALTree Thanks for the new test case, should be fixed by CL 406475.

@gopherbot
Copy link

Change https://go.dev/cl/424775 mentions this issue: cmd/compile: enable more inlining for unified IR

gopherbot pushed a commit that referenced this issue Aug 18, 2022
The non-unified frontend had repeated issues with inlining and
generics (#49309, #51909, #52907), which led us to substantially
restrict inlining when shape types were present.

However, these issues are evidently not present in unified IR's
inliner, and the safety restrictions added for the non-unified
frontend can simply be disabled in unified mode.

Fixes #54497.

Change-Id: I8e6ac9f3393c588bfaf14c6452891b9640a9d1bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/424775
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
@golang golang locked and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants