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: compiler hangs on tiny program #19783

Closed
ALTree opened this issue Mar 30, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@ALTree
Copy link
Member

commented Mar 30, 2017

go version devel +371c83b594 Thu Mar 30 02:45:45 2017 +0000 linux/amd64

The following program:

package p

func Spin() {
l1:
	for true {
		goto l1
	l2:
		if true {
			goto l2
		}
	}
}

hangs the tip compiler (spinning at 100% cpu).

It compiles in no time in go1.8

@ALTree

This comment has been minimized.

Copy link
Member Author

commented Mar 30, 2017

The issue was introduced in CL 37760 (cmd/compile: avoid generating some dead blocks).

cc @josharian

@ALTree ALTree added this to the Go1.9 milestone Mar 30, 2017

@josharian

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2017

Thanks! I have a simple fix but it touches some very hot code, so benchmarking now.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 30, 2017

CL https://golang.org/cl/38913 mentions this issue.

@gopherbot gopherbot closed this in 5272a2c Mar 30, 2017

lparth added a commit to lparth/go that referenced this issue Apr 13, 2017

cmd/compile: avoid infinite loops in dead blocks during phi insertion
Now that we no longer generate dead code,
it is possible to follow block predecessors
into infinite loops with no variable definitions,
causing an infinite loop during phi insertion.

To fix that, check explicitly whether the predecessor
is dead in lookupVarOutgoing, and if so, bail.

The loop in lookupVarOutgoing is very hot code,
so I am wary of adding anything to it.
However, a long, CPU-only benchmarking run shows no
performance impact at all.

Fixes golang#19783

Change-Id: I8ef8d267e0b20a29b5cb0fecd7084f76c6f98e47
Reviewed-on: https://go-review.googlesource.com/38913
Reviewed-by: David Chase <drchase@google.com>

@golang golang locked and limited conversation to collaborators Mar 30, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.