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
Closed

cmd/compile: compiler hangs on tiny program #19783

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

Comments

@ALTree
Copy link
Member

ALTree 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
Copy link
Member Author

ALTree 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
Copy link
Contributor

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

@gopherbot
Copy link

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

lparth pushed a commit to lparth/go that referenced this issue Apr 13, 2017
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.
Projects
None yet
Development

No branches or pull requests

3 participants