Skip to content

cmd/compile/internal/gc: bad store type when compiling an openshift origin package #42568

@derekparker

Description

@derekparker

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

$ go version
go version devel +15f01d6ae9 Thu Oct 29 03:23:51 2020 +0000 linux/amd64

This also reproduces on tip.

Does this issue reproduce with the latest release?

No, only on tip.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/deparker/.cache/go-build"
GOENV="/home/deparker/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/deparker/Code/gopath"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/deparker/Code/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build790675458=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. git clone github.com/openshift/origin
  2. cd pkg/templateservicebroker/servicebroker
  3. GO111MODULE=auto go build

What did you expect to see?

Successful compilation.

What did you see instead?

# github.com/openshift/origin/pkg/templateservicebroker/servicebroker
panic: bad store type

goroutine 1 [running]:
cmd/compile/internal/amd64.storeByType(0xc00005dec0, 0xc0006f82d0)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:78 +0x129
cmd/compile/internal/amd64.loadByType(0xc00005dec0, 0xc001a80813)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:53 +0x38
cmd/compile/internal/amd64.ssaGenValue(0xc001cfaa80, 0xc001a88340)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:950 +0x6525
cmd/compile/internal/gc.genssa(0xc001c8c6e0, 0xc001cfaa00)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/ssa.go:6319 +0x6eb
cmd/compile/internal/gc.compileSSA(0xc0001522c0, 0x0)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:329 +0x3a5
cmd/compile/internal/gc.compile(0xc0001522c0)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:277 +0x39e
cmd/compile/internal/gc.funccompile(0xc0001522c0)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:220 +0xc5
cmd/compile/internal/gc.Main(0xcb9768)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/main.go:752 +0x34af
main.main()
        /home/deparker/Code/go/src/cmd/compile/main.go:52 +0xb1

Here is some prelim debugging output I've collected about what is causing this panic to trigger:

panic: bad store type

goroutine 15 [running]:
cmd/compile/internal/amd64.storeByType(0xc000051ec0, 0xc0005a62d0)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:78 +0x129
cmd/compile/internal/amd64.loadByType(0xc000051ec0, 0xc001b00813)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:53 +0x38
cmd/compile/internal/amd64.ssaGenValue(0xc0018c2d00, 0xc001b01b90)
        /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:950 +0x6525
cmd/compile/internal/gc.genssa(0xc001dfc000, 0xc0018c2c00)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/ssa.go:6319 +0x6eb
cmd/compile/internal/gc.compileSSA(0xc0000c82c0, 0x0)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:329 +0x3a5
cmd/compile/internal/gc.compileFunctions.func2(0xc001f464e0, 0xc001e27b30, 0x0)
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:384 +0x4d
created by cmd/compile/internal/gc.compileFunctions
        /home/deparker/Code/go/src/cmd/compile/internal/gc/pgen.go:382 +0x129
(dlv) c
> [unrecovered-panic] runtime.fatalpanic() /home/deparker/Code/go/src/runtime/panic.go:1185 (hits goroutine(15):1 total:1) (PC: 0x4375a0)
Warning: debugging optimized function
        runtime.curg._panic.arg: interface {}(string) "bad store type"
Current event: 21604
  1180: // fatalpanic implements an unrecoverable panic. It is like fatalthrow, except
  1181: // that if msgs != nil, fatalpanic also prints panic messages and decrements
  1182: // runningPanicDefers once main is blocked from exiting.
  1183: //
  1184: //go:nosplit
=>1185: func fatalpanic(msgs *_panic) {
  1186:         pc := getcallerpc()
  1187:         sp := getcallersp()
  1188:         gp := getg()
  1189:         var docrash bool
  1190:         // Switch to the system stack to avoid any stack growth, which
(dlv) b /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:78
Breakpoint 1 set at 0xbadc2d for cmd/compile/internal/amd64.storeByType() /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:78
(dlv) rev continue
> cmd/compile/internal/amd64.storeByType() /home/deparker/Code/go/src/cmd/compile/internal/amd64/ssa.go:78 (hits goroutine(15):1 total:1) (PC: 0xbadc2d)
Warning: debugging optimized function
Current event: 21604
    73:                         return x86.AMOVL
    74:                 case 8:
    75:                         return x86.AMOVQ
    76:                 }
    77:         }
=>  78:         panic("bad store type")
    79: }
    80:
    81: // moveByType returns the reg->reg move instruction of the given type.
    82: func moveByType(t *types.Type) obj.As {
    83:         if t.IsFloat() {
(dlv) args
t = ("*cmd/compile/internal/types.Type")(0xc000051ec0)
~r1 = (unreadable empty OP stack)
(dlv) p t
*cmd/compile/internal/types.Type {
        Extra: interface {}(*cmd/compile/internal/types.Interface) *{
                Fields: (*"cmd/compile/internal/types.Fields")(0xc00004c670),
                pkg: *cmd/compile/internal/types.Pkg nil,},
        Width: 16,
        methods: cmd/compile/internal/types.Fields {
                s: *[]*cmd/compile/internal/types.Field nil,},
        allMethods: cmd/compile/internal/types.Fields {
                s: *[]*cmd/compile/internal/types.Field nil,},
        Nod: *cmd/compile/internal/types.Node {_: 0},
        Orig: *cmd/compile/internal/types.Type {
                Extra: interface {}(*cmd/compile/internal/types.Interface) ...,
                Width: 16,
                methods: (*"cmd/compile/internal/types.Fields")(0xc000051ed8),
                allMethods: (*"cmd/compile/internal/types.Fields")(0xc000051ee0),
                Nod: *(*"cmd/compile/internal/types.Node")(0xc0005de500),
                Orig: *(*"cmd/compile/internal/types.Type")(0xc000051ec0),
                Cache: (*"struct { cmd/compile/internal/types.ptr *cmd/compile/internal/types.Type; cmd/compile/internal/types.slice *cmd/compile/internal/types.Type }")(0xc000051ef8),
                Sym: *cmd/compile/internal/types.Sym nil,
                Vargen: 0,
                Etype: cmd/compile/internal/gc.TINTER (24),
                Align: 8,
                flags: 0,},
        Cache: struct { cmd/compile/internal/types.ptr *cmd/compile/internal/types.Type; cmd/compile/internal/types.slice *cmd/compile/internal/types.Type } {
                ptr: *(*"cmd/compile/internal/types.Type")(0xc001aa96e0),
                slice: *(*"cmd/compile/internal/types.Type")(0xc001aa97a0),},
        Sym: *cmd/compile/internal/types.Sym nil,
        Vargen: 0,
        Etype: cmd/compile/internal/gc.TINTER (24),
        Align: 8,
        flags: 0,}

I did a little bit of digging and the problem seems to be that the compiler is not properly decomposing this store into two smaller stores for some reason. I've bisected the tree from 1.15.4 where this worked and I've found the commit that introduced this bug to be 15f01d6.

I'm happy to continue working on this and submit a fix, I've spent some time tracking this down and figured I'd at least create an issue and see if there are any obvious things to look at where things may be going wrong from folks who are more familiar with the actual SSA code than I am at the present moment.

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