Skip to content

compiler crash on defer inside range-over-func #4441

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

Open
ALTree opened this issue Aug 28, 2024 · 4 comments
Open

compiler crash on defer inside range-over-func #4441

ALTree opened this issue Aug 28, 2024 · 4 comments
Labels
bug Something isn't working core

Comments

@ALTree
Copy link

ALTree commented Aug 28, 2024

$ tinygo version
tinygo version 0.33.0 linux/amd64 (using go version go1.23.0 and LLVM version 18.1.2)
package main

func main() {
	for range func(func() bool) {} {
		defer func() {}()
	}
}
$ tinygo build crash.go
panic: *ssa.opaqueType: deferStack

goroutine 10 [running]:
golang.org/x/tools/go/types/typeutil.Hasher.hashFor({0xc000585650?, 0xc000585680?, 0x0?}, {0x6524780?, 0x866af40?})
	/go/pkg/mod/golang.org/x/tools@v0.22.1-0.20240621165957-db513b091504/go/types/typeutil/map.go:375 +0x58c
golang.org/x/tools/go/types/typeutil.Hasher.Hash({0xc000585650?, 0xc000585680?, 0x0?}, {0x6524780, 0x866af40})
	/go/pkg/mod/golang.org/x/tools@v0.22.1-0.20240621165957-db513b091504/go/types/typeutil/map.go:240 +0x75
golang.org/x/tools/go/types/typeutil.Hasher.hashFor({0xc000585650?, 0xc000585680?, 0x0?}, {0x6523da8?, 0x866af30})
	/go/pkg/mod/golang.org/x/tools@v0.22.1-0.20240621165957-db513b091504/go/types/typeutil/map.go:286 +0x165
golang.org/x/tools/go/types/typeutil.Hasher.Hash({0xc000585650?, 0xc000585680?, 0x0?}, {0x6523da8, 0x866af30})

[...]
@deadprogram deadprogram added bug Something isn't working core labels Sep 9, 2024
@deadprogram
Copy link
Member

Is this issue still value for the most recent TinyGo version?

@ALTree
Copy link
Author

ALTree commented Mar 17, 2025

Is this issue still value for the most recent TinyGo version?

Crashes with the same error on 0.36

@aykevl
Copy link
Member

aykevl commented Mar 18, 2025

Reproduced locally.
Interestingly this crash happens while it is trying to report the following error:

todo: builtin: ssa:deferstack

@aykevl
Copy link
Member

aykevl commented Mar 18, 2025

So there's a ssa:deferstack call and a *deferStack type, and I'm not entirely sure what they do. I will look into it later.
I filed golang/go#72914 related to this issue (fixing that one would make it easier to fix this bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

3 participants