Skip to content

cmd/compile: "internal compiler error: schedule does not include all values" on s390x #38916

Closed

Description

@ALTree
$ 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

Activity

  1. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on May 7, 2020
  2. added this to the Go1.15 milestone on May 7, 2020
  3. self-assigned this
    on May 7, 2020
  4. mundaym commented on May 7, 2020

    @mundaym
    Member

    Thanks, I'll take a look.

  5. mariecurried commented on May 7, 2020

    @mariecurried

    Took a chance at bisecting this and commit b2790a2 showed up

  6. reopened this on May 7, 2020
  7. added
    arch-s390xIssues solely affecting the s390x architecture.
    on May 13, 2020
  8. mundaym commented on May 13, 2020

    @mundaym
    Member

    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() {
  9. gopherbot commented on May 13, 2020

    @gopherbot
    Contributor

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

  10. gopherbot commented on May 14, 2020

    @gopherbot
    Contributor

    Change https://golang.org/cl/233941 mentions this issue: cmd/compile: add test for issue 37246

  11. locked and limited conversation to collaborators on May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.arch-s390xIssues solely affecting the s390x architecture.release-blocker

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions