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: internal compiler error: panic during layout #23504

Closed
ALTree opened this issue Jan 22, 2018 · 7 comments
Closed

cmd/compile: internal compiler error: panic during layout #23504

ALTree opened this issue Jan 22, 2018 · 7 comments
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Jan 22, 2018

$ gotip version
go version devel +6104939432 Sun Jan 21 04:56:36 2018 +0000 linux/amd64

The following program:

package p

func f() {
	var B bool
	B2 := (B || B && !B) && !B
	B3 := B2 || B
	for (B3 || B2) && !B2 && B {
	}
}

crashes the go1.6, go1.7, go1.8, go1.9, and tip compilers with the following error:

# command-line-arguments
./prog.go:7:2: internal compiler error: panic during layout while compiling f:

runtime error: index out of range

goroutine 18 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc420359288, 0xc42035c140)
	/home/adonizetti/go/src/cmd/compile/internal/ssa/compile.go:38 +0xc8
panic(0xbbb7e0, 0xf9c810)
	/home/adonizetti/go/src/runtime/panic.go:502 +0x229
cmd/compile/internal/ssa.layout(0xc42035c140)
	/home/adonizetti/go/src/cmd/compile/internal/ssa/layout.go:68 +0xdca
cmd/compile/internal/ssa.Compile(0xc42035c140)
	/home/adonizetti/go/src/cmd/compile/internal/ssa/compile.go:70 +0x2bb
cmd/compile/internal/gc.buildssa(0xc420001200, 0x0, 0x0)
	/home/adonizetti/go/src/cmd/compile/internal/gc/ssa.go:223 +0xb32
cmd/compile/internal/gc.compileSSA(0xc420001200, 0x0)
	/home/adonizetti/go/src/cmd/compile/internal/gc/pgen.go:239 +0x39
cmd/compile/internal/gc.compileFunctions.func2(0xc4204a83c0, 0xc420492090, 0x0)
	/home/adonizetti/go/src/cmd/compile/internal/gc/pgen.go:289 +0x49
created by cmd/compile/internal/gc.compileFunctions
	/home/adonizetti/go/src/cmd/compile/internal/gc/pgen.go:287 +0x11c
@ALTree ALTree added this to the Go1.11 milestone Jan 22, 2018
@ALTree
Copy link
Member Author

ALTree commented Jan 22, 2018

cc @randall77

@mvdan
Copy link
Member

mvdan commented Jan 22, 2018

Has this input program already been minified somehow? I can't seem to minify it in any way.

@ALTree
Copy link
Member Author

ALTree commented Jan 22, 2018

Has this input program already been minified somehow?

Yes. When posting these I usually try to minimize the reproducer before opening an issue.

@randall77
Copy link
Contributor

Thanks for the report.
Looks like a simple invariant mistake.
The layout code assumes that if a branch prediction is marked for a block, that it must have 2 successors. However, the fuse optimization pass deletes successors and doesn't clear the branch prediction bit when it does that.
Should be simple to fix.
(Doesn't crash 1.6. Starts failing for 1.7.)

@randall77 randall77 self-assigned this Jan 22, 2018
@gopherbot
Copy link

Change https://golang.org/cl/88955 mentions this issue: cmd/compile: reset branch prediction when deleting a branch

@gopherbot
Copy link

Change https://golang.org/cl/88956 mentions this issue: cmd/compile: constant fold !true and !false

gopherbot pushed a commit that referenced this issue Feb 14, 2018
Constant fold Not of boolean constants.

Noticed while working on #23504.

Change-Id: I965705154ee7348a1a159fad4e029b922d3171b3
Reviewed-on: https://go-review.googlesource.com/88956
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
cwedgwood pushed a commit to cwedgwood/go that referenced this issue Apr 18, 2018
When we go from a branch block to a plain block, reset the
branch prediction bit. Downstream passes asssume that if the
branch prediction is set, then the block has 2 successors.

Fixes golang#23504

Change-Id: I2898ec002228b2e34fe80ce420c6939201c0a5aa
Reviewed-on: https://go-review.googlesource.com/88955
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
@gopherbot
Copy link

Change https://golang.org/cl/128855 mentions this issue: [release-branch.go1.10] cmd/compile: reset branch prediction when deleting a branch

gopherbot pushed a commit that referenced this issue Aug 9, 2018
…eting a branch

When we go from a branch block to a plain block, reset the
branch prediction bit. Downstream passes asssume that if the
branch prediction is set, then the block has 2 successors.

Fixes #23504
Fixes #26851

Change-Id: I2898ec002228b2e34fe80ce420c6939201c0a5aa
Reviewed-on: https://go-review.googlesource.com/88955
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
(cherry picked from commit 4313d77)
Reviewed-on: https://go-review.googlesource.com/128855
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
@golang golang locked and limited conversation to collaborators Aug 9, 2019
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

4 participants