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

ALTree opened this issue Mar 30, 2017 · 3 comments


None yet
3 participants
Copy link

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() {
	for true {
		goto l1
		if true {
			goto l2

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

It compiles in no time in go1.8


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


This comment has been minimized.

Copy link

commented Mar 30, 2017

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


This comment has been minimized.

Copy link

commented Mar 30, 2017

CL 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-by: David Chase <>

@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.