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/go: go list fails with 'goroutine stack exceeds' on huge project #46380

Closed
nuh-temp opened this issue May 26, 2021 · 6 comments
Closed

cmd/go: go list fails with 'goroutine stack exceeds' on huge project #46380

nuh-temp opened this issue May 26, 2021 · 6 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@nuh-temp
Copy link

nuh-temp commented May 26, 2021

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

$ go version
go version go1.16.4 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOENV="/home/ubuntu/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ubuntu/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ubuntu/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ubuntu/p/workspace/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-build3688085630=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm running the following command which is used by gopls to create a list of sources along with their dependencies:

go list -modfile=go.mod -mod=readonly -e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin workspace/...

and it fails with the following error:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc030680390 stack=[0xc030680000, 0xc050680000]
fatal error: stack overflow

runtime stack:
runtime.throw(0xa4f78e, 0xe)
        /usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:1069 +0x7ed
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:458 +0x8f
go.mod Content
module workspace

go 1.16

### What did you expect to see? Correct output of "go list" command

What did you see instead?

Error message

@seankhliao seankhliao changed the title 'go list' fails with 'goroutine stack exceeds' on huge project cmd/go: go list fails with 'goroutine stack exceeds' on huge project May 26, 2021
@seankhliao seankhliao added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 26, 2021
@seankhliao
Copy link
Member

how big is "huge project"?

@jayconrod
Copy link
Contributor

It's possible there's an infinite recursion bug somewhere, but we'll need more of the stack to track it down. Does this happen consistently? Is there more output than that?

@nuh-temp
Copy link
Author

After some investigation I found a place where it goes into infinite recursion. However I still think "go list" should be able to handle such case gracefully.

@jayconrod
Copy link
Contributor

@nuh-temp Could you please post more of the stack (at least the part where it's repeating) or provide a reproducible test case?

@jayconrod jayconrod added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 1, 2021
@nuh-temp
Copy link
Author

go-example.tar.gz

  1. Download and untar attached file tar zxvf go-example.tar.gz
  2. cd go-example
  3. go list -modfile=go.mod -mod=readonly -e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin ./...

This example is definitely broken from go run stand point:

$ go run foo/example.go
foo/example.go:4:2: found packages main (example.go) and foo (foo.go) in /home/ubuntu/p/go-example/foo

But in my case I use bazel to build the project and it allows to have multiple main packages under the same folder (which might be bad) and doesn't complain as above. Each main is separate go_binary and can be run with bazel run //:main or bazel run //foo:example

@jayconrod
Copy link
Contributor

Thanks @nuh-temp! I was able to reproduce the crash with your example. The stack is the same as the one in #25830, so I'll close this as a duplicate. The issue will be fixed in Go 1.17.

@golang golang locked and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants