Skip to content

cmd/compile: internal compiler error: panic during short circuit #33903

Closed

Description

@ALTree
$ gotip version
go version devel +7be97af2ff Wed Aug 28 05:55:52 2019 +0000 windows/amd64

The following program:

package p

func f() {
        var p, q bool
        for {
                p = p && q
        }
}

Crashes the tip compiler with the following error:

$ gotip tool compile crash.go
crash.go:5:2: internal compiler error: 'f': panic during short circuit while compiling f:

runtime error: index out of range [2] with length 2

goroutine 1 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc00008c728, 0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/compile.go:47 +0xac
panic(0xe1a8a0, 0xc000064b60)
        D:/users/ZZZZZ/alberto/other/temp/go/src/runtime/panic.go:679 +0x1c0
cmd/compile/internal/ssa.shortcircuitBlock(0xc000378e60, 0xc000000800)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/shortcircuit.go:160 +0x5f7
cmd/compile/internal/ssa.shortcircuit(0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/shortcircuit.go:69 +0x364
cmd/compile/internal/ssa.Compile(0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/compile.go:92 +0x99b
cmd/compile/internal/gc.buildssa(0xc0002bc160, 0x0, 0x0)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/ssa.go:289 +0xc15
cmd/compile/internal/gc.compileSSA(0xc0002bc160, 0x0)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:298 +0x54
cmd/compile/internal/gc.compile(0xc0002bc160)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:277 +0x33b
cmd/compile/internal/gc.funccompile(0xc0002bc160)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:222 +0xc8
cmd/compile/internal/gc.Main(0xe74da8)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/main.go:685 +0x31de
main.main()
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/main.go:51 +0xb3

goroutine 1 [running]:
runtime/debug.Stack(0xff6be0, 0xc000090008, 0x0)
        D:/users/ZZZZZ/alberto/other/temp/go/src/runtime/debug/stack.go:24 +0xa4
cmd/compile/internal/gc.Fatalf(0xc00007c140, 0x32, 0xc00009c4b0, 0x5, 0x5)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/subr.go:188 +0x298
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc00006d8f0, 0x502100000002, 0xe6a2b2, 0x2c, 0xc000314c00, 0x4, 0x4)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/ssa.go:6159 +0x1b7
cmd/compile/internal/ssa.(*Func).Fatalf(...)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/func.go:617
cmd/compile/internal/ssa.Compile.func1(0xc00008c728, 0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/compile.go:49 +0x21d
panic(0xe1a8a0, 0xc000064b60)
        D:/users/ZZZZZ/alberto/other/temp/go/src/runtime/panic.go:679 +0x1c0
cmd/compile/internal/ssa.shortcircuitBlock(0xc000378e60, 0xc000000800)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/shortcircuit.go:160 +0x5f7
cmd/compile/internal/ssa.shortcircuit(0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/shortcircuit.go:69 +0x364
cmd/compile/internal/ssa.Compile(0xc0002bc580)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/ssa/compile.go:92 +0x99b
cmd/compile/internal/gc.buildssa(0xc0002bc160, 0x0, 0x0)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/ssa.go:289 +0xc15
cmd/compile/internal/gc.compileSSA(0xc0002bc160, 0x0)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:298 +0x54
cmd/compile/internal/gc.compile(0xc0002bc160)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:277 +0x33b
cmd/compile/internal/gc.funccompile(0xc0002bc160)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/pgen.go:222 +0xc8
cmd/compile/internal/gc.Main(0xe74da8)
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/internal/gc/main.go:685 +0x31de
main.main()
        D:/users/ZZZZZ/alberto/other/temp/go/src/cmd/compile/main.go:51 +0xb3

It compiles fine on go1.12.5.

Activity

  1. added this to the Go1.14 milestone on Aug 28, 2019
  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Aug 28, 2019
  3. ALTree commented on Aug 28, 2019

    @ALTree
    MemberAuthor

    It appears that the issue was introduced in the recently committed 52ae04f (cmd/compile: improve shortcircuit pass).

    cc @josharian

  4. bcmills commented on Aug 28, 2019

    @bcmills
    Contributor
  5. josharian commented on Aug 28, 2019

    @josharian
    Contributor

    Thanks! I’ll look soon.

  6. gopherbot commented on Aug 28, 2019

    @gopherbot
    Contributor

    Change https://golang.org/cl/192144 mentions this issue: cmd/compile: handle infinite loops in shortcircuit pass

  7. added a commit that references this issue on Sep 1, 2019
    401dc02
  8. added a commit that references this issue on Sep 5, 2019
    b7be5a7
  9. locked and limited conversation to collaborators on Aug 28, 2020
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.release-blocker

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions