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 · 4 comments
Closed
Assignees
Labels
NeedsFix release-blocker
Milestone

Comments

@ALTree
Copy link
Member

@ALTree 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 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 release-blocker and removed NeedsInvestigation labels May 14, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented May 14, 2022

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

@ALTree
Copy link
Member Author

@ALTree 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

@gopherbot gopherbot commented May 15, 2022

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 cuonglm commented May 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants