Skip to content

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

Closed

Description

@ALTree
$ gotip version
go version devel go1.17-da7496d841 Tue May 4 17:37:39 2021 +0000 linux/amd64
package p

func f() {
	_ = func() func() {
		return func() {
		l:
			goto l
		}
	}()
}
$ gotip tool compile crash.go

crash.go:9:3: internal compiler error: 'f.func2': panic during short circuit while compiling f.func2:

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

goroutine 9 [running]:
cmd/compile/internal/ssa.Compile.func1()
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:48 +0x71
panic({0xcb8f80, 0xc000026b10})
	/home/alberto/go/src/runtime/panic.go:1038 +0x215
cmd/compile/internal/ssa.fuseBlockPlain(0x725c20)
	/home/alberto/go/src/cmd/compile/internal/ssa/fuse.go:178 +0x554
cmd/compile/internal/ssa.fuse(0xc00037dd40, 0x11)
	/home/alberto/go/src/cmd/compile/internal/ssa/fuse.go:41 +0x19d
cmd/compile/internal/ssa.shortcircuit(0xc00037dd40)
	/home/alberto/go/src/cmd/compile/internal/ssa/shortcircuit.go:61 +0x85
cmd/compile/internal/ssa.Compile(0xc00037dd40)
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:96 +0x9e7
cmd/compile/internal/ssagen.buildssa(0xc00013ab00, 0x0)
	/home/alberto/go/src/cmd/compile/internal/ssagen/ssa.go:642 +0x1ddd
cmd/compile/internal/ssagen.Compile(0xc00013ab00, 0x0)
	/home/alberto/go/src/cmd/compile/internal/ssagen/pgen.go:165 +0x4c
cmd/compile/internal/gc.compileFunctions.func2.1()
	/home/alberto/go/src/cmd/compile/internal/gc/compile.go:136 +0x65
created by cmd/compile/internal/gc.compileFunctions.func2
	/home/alberto/go/src/cmd/compile/internal/gc/compile.go:134 +0xcf

The program compiles fine in Go1.16.

Reduced from a gosmith crasher.

cc @mdempsky

Activity

  1. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on May 4, 2021
  2. added this to the Go1.17 milestone on May 4, 2021
  3. mdempsky commented on May 4, 2021

    @mdempsky
    Contributor

    Seems like another case of inlining and function closures.

    /cc @danscales

  4. gopherbot commented on May 5, 2021

    @gopherbot
    Contributor

    Change https://golang.org/cl/316931 mentions this issue: cmd/compile: do not substitute OGOTO inside a closure when inlining

  5. locked and limited conversation to collaborators on May 5, 2022
  6. added a commit that references this issue on Apr 29, 2024
    95dde3f
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.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions