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

Closed
ALTree opened this issue May 7, 2020 · 5 comments
Labels
arch-s390x Issues solely affecting the s390x architecture. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@ALTree
Copy link
Member

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
cmd/compile/internal/ssa.(*Func).Fatalf(...)
	/home/alberto/go/src/cmd/compile/internal/ssa/func.go:625
cmd/compile/internal/ssa.schedule(0xc0000b6840)
	/home/alberto/go/src/cmd/compile/internal/ssa/schedule.go:306 +0x1baa
cmd/compile/internal/ssa.Compile(0xc0000b6840)
	/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 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels May 7, 2020
@ALTree ALTree added this to the Go1.15 milestone May 7, 2020
@mundaym mundaym self-assigned this May 7, 2020
@mundaym
Copy link
Member

mundaym commented May 7, 2020

Thanks, I'll take a look.

@mariecurried
Copy link

Took a chance at bisecting this and commit b2790a2 showed up

@ALTree ALTree closed this as completed May 7, 2020
@ALTree ALTree reopened this May 7, 2020
@mundaym mundaym added the arch-s390x Issues solely affecting the s390x architecture. label May 13, 2020
@mundaym
Copy link
Member

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 {
                                continue
                        }
--                      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)
++                              }
                                continue
                        }
                        if !v.Args[0].Type.IsTuple() {

@gopherbot
Copy link

Change https://golang.org/cl/233857 mentions this issue: cmd/compile: fix tuple selector bug in CSE pass

@gopherbot
Copy link

Change https://golang.org/cl/233941 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
Reviewed-on: https://go-review.googlesource.com/c/go/+/233941
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
@golang golang locked and limited conversation to collaborators May 14, 2021
@rsc rsc unassigned mundaym Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-s390x Issues solely affecting the s390x architecture. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants