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: panic while running compiler: index out of range during lowered cse #17918

Closed
philhofer opened this issue Nov 14, 2016 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@philhofer
Copy link
Contributor

philhofer commented Nov 14, 2016

What version of Go are you using (go version)?

go version devel +9e04097 Wed Sep 7 19:07:38 2016 +0000 linux/amd64
(sha 794fb71)

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

Run 'go install'

What did you expect to see?

Nothing (this code compiles correctly under 1.7.3)

What did you see instead?

<REDACTED>: internal compiler error: panic during lowered cse while compiling <REDACTED>: 
runtime error: index out of range

goroutine 1 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc420e28b20, 0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/compile.go:36 +0xc8
panic(0xa513c0, 0xd47720)
        /home/phil/gopath/go/src/runtime/panic.go:489 +0x2cf
cmd/compile/internal/ssa.cse(0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/cse.go:191 +0x21c6
cmd/compile/internal/ssa.Compile(0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/compile.go:68 +0x304
cmd/compile/internal/gc.buildssa(0xc42088c900, 0x0)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/ssa.go:177 +0x8fe
cmd/compile/internal/gc.compile(0xc42088c900)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/pgen.go:362 +0x204
cmd/compile/internal/gc.funccompile(0xc42088c900)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/dcl.go:1292 +0xdc
cmd/compile/internal/gc.Main()
        /home/phil/gopath/go/src/cmd/compile/internal/gc/main.go:460 +0x1f0a
main.main()
        /home/phil/gopath/go/src/cmd/compile/main.go:50 +0xfe

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
        /home/phil/gopath/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0xaae85e, 0x2c, 0xc421371440, 0x4, 0x4)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/subr.go:165 +0x226
cmd/compile/internal/gc.(*ssaExport).Fatalf(0xdbccd5, 0x27c, 0xaae85e, 0x2c, 0xc421371440, 0x4, 0x4)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/ssa.go:4976 +0x5d
cmd/compile/internal/ssa.(*Config).Fatalf(0xc420f1e000, 0xc40000027c, 0xaae85e, 0x2c, 0xc421371440, 0x4, 0x4)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/config.go:343 +0x6e
cmd/compile/internal/ssa.(*Func).Fatalf(0xc421378c60, 0xaae85e, 0x2c, 0xc421371440, 0x4, 0x4)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/func.go:413 +0x6b
cmd/compile/internal/ssa.Compile.func1(0xc420e28b20, 0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/compile.go:38 +0x250
panic(0xa513c0, 0xd47720)
        /home/phil/gopath/go/src/runtime/panic.go:489 +0x2cf
cmd/compile/internal/ssa.cse(0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/cse.go:191 +0x21c6
cmd/compile/internal/ssa.Compile(0xc421378c60)
        /home/phil/gopath/go/src/cmd/compile/internal/ssa/compile.go:68 +0x304
cmd/compile/internal/gc.buildssa(0xc42088c900, 0x0)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/ssa.go:177 +0x8fe
cmd/compile/internal/gc.compile(0xc42088c900)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/pgen.go:362 +0x204
cmd/compile/internal/gc.funccompile(0xc42088c900)
        /home/phil/gopath/go/src/cmd/compile/internal/gc/dcl.go:1292 +0xdc
cmd/compile/internal/gc.Main()
        /home/phil/gopath/go/src/cmd/compile/internal/gc/main.go:460 +0x1f0a
main.main()
        /home/phil/gopath/go/src/cmd/compile/main.go:50 +0xfe

I'll try to isolate a test case; this is all I have at the moment.

@ianlancetaylor ianlancetaylor changed the title compiler panic: index out of range during lowered cse cmd/compile: panic while running compiler: index out of range during lowered cse Nov 14, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.8 milestone Nov 14, 2016
@ianlancetaylor
Copy link
Contributor

CC @randall77 @josharian

@philhofer
Copy link
Contributor Author

Isolated test case:

package main

import (
        "fmt"
        "time"
)

var (
        iqlTimeUnits = []struct {
                divisor time.Duration
                unit    rune
        }{
                {1000000, 's'},                                                                                       
                {60, 'm'},                                                                                            
                {60, 'h'},                                                                                            
                {24, 'd'},                                                                                            
                {7, 'w'},
        }
)

func foobar(d time.Duration) string {
        d /= time.Microsecond
        unit := 'u'

        for _, f := range iqlTimeUnits {
                if d%f.divisor != 0 {
                        break
                }
                d /= f.divisor
                unit = f.unit
        }
        return fmt.Sprintf("%d%c", d, unit)
}

func main() {
        println(foobar(time.Second))
}

@philhofer
Copy link
Contributor Author

Confirmed this is still an issue at the current head commit (bb00a8d)

@philhofer
Copy link
Contributor Author

philhofer commented Nov 15, 2016

Based on my superficial reading of the code in question (lines 180-200 in ssa/cse.go), it looks like rewrite[v.ID] goes out of bounds because v.copyInto(t.Block) (line 210) can create new ssa IDs (via (*Value).copyInto() -> (*Block).NewValue0() -> (*Func).newValue() -> (*idAlloc).get())

@gopherbot
Copy link

CL https://golang.org/cl/33240 mentions this issue.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 16, 2016
@golang golang locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants