-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
ebiten: running a pulled iterator can crash the game #3042
Comments
The problem is that Ebitengine calls Actually, this works without crashing: package main
import (
"iter"
"github.com/hajimehoshi/ebiten/v2"
)
type Game struct {
next func() (int, bool)
}
func (g *Game) Update() error {
g.next()
return nil
}
func (g *Game) Draw(screen *ebiten.Image) {
}
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return outsideWidth, outsideHeight
}
func main() {
var next func() (int, bool)
ch := make(chan struct{})
go func() {
seq := func(yield func(int) bool) {
for {
if !yield(0) {
break
}
}
}
next, _ = iter.Pull(seq)
close(ch)
}()
<-ch
g := &Game{
next: next,
}
if err := ebiten.RunGame(g); err != nil {
panic(err)
}
} |
Related: golang/go#67694 We might not need |
Sorry, 3d385ef doesn't fix the issue. |
I think this is not a fixable issue unless |
Ebitengine Version
52820e2
Operating System
Go Version (
go version
)go version go1.23rc1 darwin/arm64
What steps will reproduce the problem?
Run this program with Go 1.23 (rc1):
What is the expected result?
No crash
What happens instead?
Crash:
Anything else you feel useful to add?
Reported by @eihigh
If needed, let's backport the fix to 2.7
The text was updated successfully, but these errors were encountered: