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: unexpected frame offset for open-coded defer #61895

Closed
ALTree opened this issue Aug 9, 2023 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@ALTree
Copy link
Member

ALTree commented Aug 9, 2023

$ gotip version
go version devel go1.22-a3ced4a Wed Aug 9 03:13:11 2023 +0000 linux/amd64
package main

func main() {
	for {
	}

	defer func() {}()
	defer func() {}()
}
$ gotip build crash.go 
# command-line-arguments
./crash.go:3:6: internal compiler error: unexpected frame offset for open-coded defer slot #1: have 1, want 8

goroutine 21 [running]:
runtime/debug.Stack()
	./desktop/gotip/src/runtime/debug/stack.go:24 +0x5e
cmd/compile/internal/base.FatalfAt({0x0?, 0x0?}, {0xd9b303, 0x47}, {0xc000629748, 0x3, 0x3})
	./desktop/gotip/src/cmd/compile/internal/base/print.go:230 +0x1d7
cmd/compile/internal/ssagen.(*state).emitOpenDeferInfo(0xc0000c6300)
	./desktop/gotip/src/cmd/compile/internal/ssagen/ssa.go:294 +0x145
cmd/compile/internal/ssagen.buildssa(0xc0003bf760, 0x3)
	./desktop/gotip/src/cmd/compile/internal/ssagen/ssa.go:575 +0x2b25
cmd/compile/internal/ssagen.Compile(0xc0003bf760, 0x0?)
	./desktop/gotip/src/cmd/compile/internal/ssagen/pgen.go:208 +0x45
cmd/compile/internal/gc.compileFunctions.func5.1(0xc0003b3a00?)
	./desktop/gotip/src/cmd/compile/internal/gc/compile.go:184 +0x34
cmd/compile/internal/gc.compileFunctions.func3.1()
	./desktop/gotip/src/cmd/compile/internal/gc/compile.go:166 +0x30
created by cmd/compile/internal/gc.compileFunctions.func3 in goroutine 20
	./desktop/gotip/src/cmd/compile/internal/gc/compile.go:165 +0x23a

Silly control flow but reporting anyway in case it's a symptom of a more serious issue.

Doesn't crash on go1.21.

cc @golang/compiler

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 9, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 9, 2023
@randall77
Copy link
Contributor

@mdempsky

@mdempsky mdempsky self-assigned this Aug 9, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/517856 mentions this issue: cmd/compile: keep all open-coded defer slots as used

@mdempsky
Copy link
Contributor

mdempsky commented Aug 9, 2023

Thanks for the test case. I suspected unreachable defer statements could be an issue, but when I tried testing it like:

	x := false
	if x {
		defer func() {}()
		defer func() {}()
	}

it didn't fail.

I'm curious why it triggers with the for loop instead.

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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants