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: schedule does not include all values" on s390x #38916

ALTree opened this issue May 7, 2020 · 5 comments


Copy link

@ALTree ALTree commented May 7, 2020

$ gotip version
go version devel +176481990f Thu May 7 07:06:11 2020 +0000 linux/amd64

This program:

package p

func f() {
	var b bool
	var c complex128
	_ = func(p complex128) complex128 {
		b = (p+1i == 0) && b
		return (p + 2i) * (p + 3i - c)

Crashes the tip compiler, when built for s390x, with the following error:

$ GOARCH=s390x gotip build crash.go 

# command-line-arguments
./crash.go:7:19: internal compiler error: 'f.func1': schedule does not include all values in block b2

goroutine 9 [running]:
runtime/debug.Stack(0xd48b00, 0xc00000e018, 0x0)
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x9f
cmd/compile/internal/gc.Fatalf(0xc00051a1c0, 0x36, 0xc0003461a0, 0x2, 0x2)
	/home/alberto/go/src/cmd/compile/internal/gc/subr.go:193 +0x1b0
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc000065d10, 0x713000000002, 0xc61a63, 0x30, 0xc0005121d0, 0x1, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:6839 +0x1a5
	/home/alberto/go/src/cmd/compile/internal/ssa/schedule.go:306 +0x1baa
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:93 +0x9d1
cmd/compile/internal/gc.buildssa(0xc0000b6420, 0x1, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:460 +0xd25
cmd/compile/internal/gc.compileSSA(0xc0000b6420, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:296 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc000370a80, 0xc000014930, 0x1)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:361 +0x4d
created by cmd/compile/internal/gc.compileFunctions
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:359 +0x129

It compiles fine on Go1.14.2.

The root cause may be similar to the one for #37246, but the reproducers in #37246 do not crash the 1.14.2 nor the tip compilers, while the program above does crash current tip.

cc @randall77 @mundaym @ruixin-bao

@ALTree ALTree added this to the Go1.15 milestone May 7, 2020
@mundaym mundaym self-assigned this May 7, 2020
Copy link

@mundaym mundaym commented May 7, 2020

Thanks, I'll take a look.

Copy link

@marigonzes marigonzes commented May 7, 2020

Took a chance at bisecting this and commit b2790a2 showed up

@ALTree ALTree closed this May 7, 2020
@ALTree ALTree reopened this May 7, 2020
@mundaym mundaym added the arch-s390x label May 13, 2020
Copy link

@mundaym mundaym commented May 13, 2020

This is a bug in the CSE pass. There is a subtle bug in the way tuple selection ops are fixed up so that they are in the correct block. The failure can be exposed using this patch:

diff --cc src/cmd/compile/internal/ssa/cse.go
index 15dfe6d795,15dfe6d795..b61c36b128
--- a/src/cmd/compile/internal/ssa/cse.go
+++ b/src/cmd/compile/internal/ssa/cse.go
@@@ -201,10 -201,10 +201,16 @@@ func cse(f *Func) 
                        // New values are created when selectors are copied to
                        // a new block. We can safely ignore those new values,
                        // since they have already been copied (issue 17918).
--                      if int(v.ID) >= len(rewrite) || rewrite[v.ID] != nil {
++                      if v.Op != OpSelect0 && v.Op != OpSelect1 {
--                      if v.Op != OpSelect0 && v.Op != OpSelect1 {
++                      if int(v.ID) >= len(rewrite) {
++                              continue
++                      }
++                      if x := rewrite[v.ID]; x != nil {
++                              if y := rewrite[x.Args[0].ID]; y != nil && x.Block != y.Block {
++                                      f.Fatalf("rewrite to dead tuple selector: %v -> %v", v, x)
++                              }
                        if !v.Args[0].Type.IsTuple() {
Copy link

@gopherbot gopherbot commented May 13, 2020

Change mentions this issue: cmd/compile: fix tuple selector bug in CSE pass

@gopherbot gopherbot closed this in f073395 May 14, 2020
Copy link

@gopherbot gopherbot commented May 14, 2020

Change mentions this issue: cmd/compile: add test for issue 37246

gopherbot pushed a commit that referenced this issue May 14, 2020
CL 233857 fixed the underlying issue for #37246,
which had arisen again as #38916.

Add the test case from #37246 to ensure it stays fixed.

Fixes #37246

Change-Id: If7fd75a096d2ce4364dc15509253c3882838161d
Run-TryBot: Josh Bleecher Snyder <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Michael Munday <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.