Skip to content

cmd/compile: stack overflow on invalid recursive map key type #22501

Closed

Description

@pandaman64

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

go version go1.9.2 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/md304/ua095595/go"
GORACE=""
GOROOT="/work/ua095595/golang/go"
GOTOOLDIR="/work/ua095595/golang/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build067689458=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

I declared a struct(Group) that has a map whose key is an invalid recursive type(Cell), and compiled it.
This is the minimal code which causes this bug:
https://play.golang.org/p/TgiCsMyeb-

What did you expect to see?

The compiler compiles the source or reports some errors without a crash.

What did you see instead?

The compiler caused a stack overflow.
Here is the message on crash:

# command-line-arguments
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0xb5f620, 0xe)
        /usr/local/go/src/runtime/panic.go:605 +0x95
runtime.newstack(0x0)
        /usr/local/go/src/runtime/stack.go:1050 +0x6e1
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:415 +0x86

goroutine 1 [running]:
cmd/compile/internal/types.(*Type).FieldSlice(0xc420341860, 0x0, 0x0, 0x0)
        /usr/local/go/src/cmd/compile/internal/types/type.go:832 +0x6a fp=0xc44033e340 sp=0xc44033e338 pc=0x4d7c4a
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:157 +0x30f fp=0xc44033e3b8 sp=0xc44033e340 pc=0x92dcff
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:161 +0x469 fp=0xc44033e430 sp=0xc44033e3b8 pc=0x92de59
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:161 +0x469 fp=0xc44033e4a8 sp=0xc44033e430 pc=0x92de59
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:161 +0x469 fp=0xc44033e520 sp=0xc44033e4a8 pc=0x92de59
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:161 +0x469 fp=0xc44033e598 sp=0xc44033e520 pc=0x92de59
cmd/compile/internal/gc.algtype1(0xc420341860, 0xc42000c548, 0x1)
        /usr/local/go/src/cmd/compile/internal/gc/alg.go:161 +0x469 fp=0xc44033e610 sp=0xc44033e598 pc=0x92de59
...similar lines continue...

Activity

  1. changed the title [-]Compiler stack overflow when compiling a map whose key is an invalid recursive type[/-] [+]cmd/compile: stack overflow on invalid recursive map key type[/+] on Oct 31, 2017
  2. self-assigned this
    on Oct 31, 2017
  3. added this to the Go1.10 milestone on Oct 31, 2017
  4. odeke-em commented on Oct 31, 2017

    @odeke-em
    Member

    @mdempsky this looks quite familiar to #21657. Perhaps this issue is a duplicate? What do you think?

  5. mdempsky commented on Oct 31, 2017

    @mdempsky
    Contributor

    @odeke-em Yes, duplicate of #21657.

  6. locked and limited conversation to collaborators on Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions