Skip to content

miscompilation of a break after a range-loop #4884

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
eliasnaur opened this issue May 3, 2025 · 0 comments
Open

miscompilation of a break after a range-loop #4884

eliasnaur opened this issue May 3, 2025 · 0 comments
Labels
bug Something isn't working core next-release Will be part of next release

Comments

@eliasnaur
Copy link
Contributor

This program runs forever on TinyGo:

package main

import (
	"fmt"
	"iter"
)

func splitSeq() iter.Seq[string] {
	return func(yield func(string) bool) {
	}
}

func main() {
	fmt.Println("start")
	defer fmt.Println("finish")
	for {
		for range splitSeq() {
		}
		break
	}
}

To reproduce:

$ go run stub2.go
start
finish
$ tinygo version
tinygo version 0.38.0-dev-612a38e3 darwin/arm64 (using go version go1.24.2 and LLVM version 18.1.8)
$ tinygo run stub2.go
start
<hang>

Adding an explicit break target fixes the hang:

package main

import (
	"fmt"
	"iter"
)

func splitSeq() iter.Seq[string] {
	return func(yield func(string) bool) {
	}
}

func main() {
	fmt.Println("start")
	defer fmt.Println("finish")
loop:
	for {
		for range splitSeq() {
		}
		break loop
	}
}
$ tinygo run stub3.go
start
finish
eliasnaur added a commit to eliasnaur/tinygo that referenced this issue May 3, 2025
Fixes tinygo-org#4884 by upgrading the ssa package.

The fix is in v0.26.0, which also bumps the minimum Go to 1.22. The
latest x/tools module still depending on 1.22 is v0.30.0.
eliasnaur added a commit to eliasnaur/tinygo that referenced this issue May 3, 2025
Fixes tinygo-org#4884 by upgrading the ssa package.

The fix is in v0.26.0, which also bumps the minimum Go to 1.22. The
latest x/tools module still depending on 1.22 is v0.30.0.
eliasnaur added a commit to eliasnaur/tinygo that referenced this issue May 3, 2025
Fixes tinygo-org#4884 by upgrading the ssa package.

The fix is in v0.26.0, which also bumps the minimum Go to 1.22. The
latest x/tools module still depending on 1.22 is v0.30.0.
eliasnaur added a commit to eliasnaur/tinygo that referenced this issue May 4, 2025
Fixes tinygo-org#4884 by upgrading the ssa package.

The fix is in v0.26.0, which also bumps the minimum Go to 1.22. The
latest x/tools module still depending on 1.22 is v0.30.0.
deadprogram pushed a commit that referenced this issue May 6, 2025
Fixes #4884 by upgrading the ssa package.

The fix is in v0.26.0, which also bumps the minimum Go to 1.22. The
latest x/tools module still depending on 1.22 is v0.30.0.
@deadprogram deadprogram added bug Something isn't working next-release Will be part of next release core labels May 6, 2025
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 next-release Will be part of next release
Projects
None yet
Development

No branches or pull requests

2 participants