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/gofmt: gofmt -r stack overflow when trying to rewrite functions #14821

Open
KamilaBorowska opened this issue Mar 14, 2016 · 0 comments
Open
Milestone

Comments

@KamilaBorowska
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
go version go1.6 linux/amd64
  1. What operating system and processor architecture are you using (go env)?

Arch Linux

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xfix/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

Tried to rewrite functions with gofmt.

echo 'package main; var X = func() {}' | gofmt -r 'func() -> func(A B)'
  1. What did you expect to see?

Function converted into var X = func(A B) {}.

  1. What did you see instead?
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x5c1c90, 0xe)
        /usr/lib/go/src/runtime/panic.go:530 +0x90
runtime.newstack()
        /usr/lib/go/src/runtime/stack.go:940 +0xb11
runtime.morestack()
        /usr/lib/go/src/runtime/asm_amd64.s:359 +0x7f

goroutine 1 [stack growth]:
runtime.mallocgc(0x8, 0x578ec0, 0x1, 0x0)
        /usr/lib/go/src/runtime/malloc.go:499 fp=0xc840100320 sp=0xc840100318
runtime.newobject(0x578ec0, 0x0)
        /usr/lib/go/src/runtime/malloc.go:781 +0x42 fp=0xc840100348 sp=0xc840100320
reflect.unsafe_New(0x578ec0, 0x0)
        /usr/lib/go/src/runtime/malloc.go:786 +0x21 fp=0xc840100360 sp=0xc840100348
reflect.packEface(0x578ec0, 0xc82000e4a0, 0x182, 0x0, 0x0)
        /usr/lib/go/src/reflect/value.go:112 +0xf9 fp=0xc8401003d0 sp=0xc840100360
reflect.valueInterface(0x578ec0, 0xc82000e4a0, 0x182, 0x1, 0x0, 0x0)
        /usr/lib/go/src/reflect/value.go:938 +0x1ec fp=0xc840100428 sp=0xc8401003d0
reflect.Value.Interface(0x578ec0, 0xc82000e4a0, 0x182, 0x0, 0x0)
        /usr/lib/go/src/reflect/value.go:908 +0x48 fp=0xc840100460 sp=0xc840100428
main.subst(0xc8600ff8b0, 0x578ec0, 0xc82000e4a0, 0x182, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:265 +0x3a6 fp=0xc840100698 sp=0xc840100460
main.subst(0xc8600ff8b0, 0x588b20, 0xc82000e4a0, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc8401008d0 sp=0xc840100698
main.subst(0xc8600ff8b0, 0x5994a0, 0xc820028038, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840100b08 sp=0xc8401008d0
main.subst(0xc8600ff8b0, 0x539360, 0xc820012508, 0x197, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:276 +0xb97 fp=0xc840100d40 sp=0xc840100b08
main.subst(0xc8600ff8b0, 0x596480, 0xc820012500, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840100f78 sp=0xc840100d40
main.subst(0xc8600ff8b0, 0x581a60, 0xc820012500, 0x16, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc8401011b0 sp=0xc840100f78
main.subst(0xc8600ff8b0, 0x542060, 0xc8200161a8, 0x194, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:297 +0x62c fp=0xc8401013e8 sp=0xc8401011b0
main.subst(0xc8600ff8b0, 0x596b60, 0xc820016190, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840101620 sp=0xc8401013e8
main.subst(0xc8600ff8b0, 0x579c80, 0xc82000e4b8, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840101858 sp=0xc840101620
main.subst(0xc8600ff8b0, 0x588b20, 0xc82000e4a0, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840101a90 sp=0xc840101858
main.subst(0xc8600ff8b0, 0x5994a0, 0xc820028038, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840101cc8 sp=0xc840101a90
main.subst(0xc8600ff8b0, 0x539360, 0xc820012508, 0x197, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:276 +0xb97 fp=0xc840101f00 sp=0xc840101cc8
main.subst(0xc8600ff8b0, 0x596480, 0xc820012500, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840102138 sp=0xc840101f00
main.subst(0xc8600ff8b0, 0x581a60, 0xc820012500, 0x16, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840102370 sp=0xc840102138
main.subst(0xc8600ff8b0, 0x542060, 0xc8200161a8, 0x194, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:297 +0x62c fp=0xc8401025a8 sp=0xc840102370
main.subst(0xc8600ff8b0, 0x596b60, 0xc820016190, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc8401027e0 sp=0xc8401025a8
main.subst(0xc8600ff8b0, 0x579c80, 0xc82000e4b8, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840102a18 sp=0xc8401027e0
main.subst(0xc8600ff8b0, 0x588b20, 0xc82000e4a0, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840102c50 sp=0xc840102a18
main.subst(0xc8600ff8b0, 0x5994a0, 0xc820028038, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840102e88 sp=0xc840102c50
main.subst(0xc8600ff8b0, 0x539360, 0xc820012508, 0x197, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:276 +0xb97 fp=0xc8401030c0 sp=0xc840102e88
main.subst(0xc8600ff8b0, 0x596480, 0xc820012500, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc8401032f8 sp=0xc8401030c0
main.subst(0xc8600ff8b0, 0x581a60, 0xc820012500, 0x16, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840103530 sp=0xc8401032f8
main.subst(0xc8600ff8b0, 0x542060, 0xc8200161a8, 0x194, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:297 +0x62c fp=0xc840103768 sp=0xc840103530
main.subst(0xc8600ff8b0, 0x596b60, 0xc820016190, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc8401039a0 sp=0xc840103768
main.subst(0xc8600ff8b0, 0x579c80, 0xc82000e4b8, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840103bd8 sp=0xc8401039a0
main.subst(0xc8600ff8b0, 0x588b20, 0xc82000e4a0, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc840103e10 sp=0xc840103bd8
main.subst(0xc8600ff8b0, 0x5994a0, 0xc820028038, 0x196, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc840104048 sp=0xc840103e10
main.subst(0xc8600ff8b0, 0x539360, 0xc820012508, 0x197, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:276 +0xb97 fp=0xc840104280 sp=0xc840104048
main.subst(0xc8600ff8b0, 0x596480, 0xc820012500, 0x199, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:283 +0xe29 fp=0xc8401044b8 sp=0xc840104280
main.subst(0xc8600ff8b0, 0x581a60, 0xc820012500, 0x16, 0x578ec0, 0xc8200105a0, 0x82, 0x0, 0x0, 0x0)
        /usr/lib/go/src/cmd/gofmt/rewrite.go:290 +0x843 fp=0xc8401046f0 sp=0xc8401044b8
@bradfitz bradfitz changed the title gofmt causes stack overflow when trying to rewrite functions into different functions (with at least one argument) cmd/gofmt: gofmt -r stack overflow when trying to rewrite functions Mar 14, 2016
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants