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: panic during fuse with if true block containing a goto and a return #28616

Closed
helloPiers opened this issue Nov 6, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@helloPiers
Copy link

commented Nov 6, 2018

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Reproduces on playground, master branch, and Go v1.11.2.
Doesn't reproduce on Go v1.10.5.

What did you do?

Tried to compile code which I've boiled down to:
https://play.golang.org/p/2fEsQtceadQ

What did you expect to see?

Compilation success

What did you see instead?

prog.go:5:2: internal compiler error: 'f1': panic during fuse while compiling f1:

runtime error: index out of range

goroutine 20 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc000403218, 0xc00034c6e0)
	/usr/local/go/src/cmd/compile/internal/ssa/compile.go:38 +0xc6
panic(0xc445e0, 0x12dc7e0)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
cmd/compile/internal/ssa.fuseBlockPlain(0xc0003dfce8, 0x47be00)
	/usr/local/go/src/cmd/compile/internal/ssa/fuse.go:123 +0x781
...

@ianlancetaylor ianlancetaylor changed the title compiler: panic during fuse with if true block containing a goto and a return cmd/compile: panic during fuse with if true block containing a goto and a return Nov 6, 2018

@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Nov 6, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

@gopherbot please open a backport for 1.11

@gopherbot

This comment has been minimized.

Copy link

commented Nov 6, 2018

Backport issue(s) opened: #28617 (for 1.11).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@randall77

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

@quasilyte I believe your CL https://go-review.googlesource.com/c/go/+/91056 is the cause.
In cmd/compile/internal/gc/typecheck.go:deadcode, we remove everything from a function after an if true { ... return } pattern. But we can't do that if, inside that if, there is a goto to a label which occurs after the if.

@gopherbot

This comment has been minimized.

Copy link

commented Nov 6, 2018

Change https://golang.org/cl/147817 mentions this issue: cmd/compile: don't deadcode eliminate labels

@gopherbot gopherbot closed this in 95a4f79 Nov 6, 2018

@quasilyte

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

@randall77, thanks for quickly fixing it.
My mistake without a doubt.

@helloPiers, thanks for reporting it! 👍

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