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: stack overflow on invalid recursive map key type #22501

Closed
pandaman64 opened this issue Oct 31, 2017 · 2 comments
Closed

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

pandaman64 opened this issue Oct 31, 2017 · 2 comments
Milestone

Comments

@pandaman64
Copy link

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...
@mdempsky mdempsky 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 Oct 31, 2017
@mdempsky mdempsky self-assigned this Oct 31, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Oct 31, 2017
@odeke-em
Copy link
Member

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

@mdempsky
Copy link
Member

@odeke-em Yes, duplicate of #21657.

@golang golang locked and limited conversation to collaborators Oct 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants