Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stack overflow when loading project with cyclic dependencies #1484

Closed
Qendolin opened this issue May 7, 2021 · 3 comments
Closed

Stack overflow when loading project with cyclic dependencies #1484

Qendolin opened this issue May 7, 2021 · 3 comments

Comments

@Qendolin
Copy link

Qendolin commented May 7, 2021

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.16.4 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.6.11
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.55.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.24.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
GOBIN: undefined
toolsGopath: 
gopath: C:\Users\ICH\AppData\Local\go
GOROOT: C:\Program Files\go
PATH: C:\Program Files\go\bin;C:\Program Files\AdoptOpenJDK\jdk-15.0.1.9-hotspot\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;C:\Program Files\Python38\Scripts\;C:\Program Files\Python38\;C:\Program Files\Oculus\Support\oculus-runtime;C:\Program Files\AdoptOpenJDK\jdk-13.0.1.9-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\dotnet\;c:\Program Files\mingw-w64\mingw64\bin\;c:\Portable\MinGW\msys\1.0\bin\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Go\bin;C:\Users\ICH\AppData\Local\Microsoft\WindowsApps;C:\Users\ICH\go\bin;C:\Users\ICH\AppData\Local\GitHubDesktop\bin;C:\Users\ICH\AppData\Local\go\bin\;C:\Users\ICH\.dotnet\tools;C:\Program Files\heroku\bin;c:\Users\ICH\AppData\Local\flutter\bin\;C:\Users\ICH\AppData\Roaming\npm;C:\Users\ICH\AppData\Local\Microsoft\WindowsApps;C:\Users\ICH\.dotnet\tools;C:\Users\ICH\go\bin

   gopkgs: C:\Users\ICH\AppData\Local\go\bin\gopkgs.exe installed
   go-outline: C:\Users\ICH\AppData\Local\go\bin\go-outline.exe installed
   gotests: C:\Users\ICH\AppData\Local\go\bin\gotests.exe installed
   gomodifytags: C:\Users\ICH\AppData\Local\go\bin\gomodifytags.exe installed
   impl: C:\Users\ICH\AppData\Local\go\bin\impl.exe installed
   goplay: C:\Users\ICH\AppData\Local\go\bin\goplay.exe installed
   dlv: C:\Users\ICH\AppData\Local\go\bin\dlv.exe installed
   dlv-dap: C:\Users\ICH\AppData\Local\go\bin\dlv-dap.exe installed
   staticcheck: C:\Users\ICH\AppData\Local\go\bin\staticcheck.exe installed
   gopls: C:\Users\ICH\AppData\Local\go\bin\gopls.exe installed

go env
Workspace Folder (go-printpixel): c:\Users\ICH\Documents\_dev\cloud\go-printpixel
	set GO111MODULE=
	set GOARCH=amd64
	set GOBIN=
	set GOCACHE=C:\Users\ICH\AppData\Local\go-build
	set GOENV=C:\Users\ICH\AppData\Roaming\go\env
	set GOEXE=.exe
	set GOFLAGS=
	set GOHOSTARCH=amd64
	set GOHOSTOS=windows
	set GOINSECURE=
	set GOMODCACHE=C:\Users\ICH\AppData\Local\go\pkg\mod
	set GONOPROXY=
	set GONOSUMDB=
	set GOOS=windows
	set GOPATH=C:\Users\ICH\AppData\Local\go
	set GOPRIVATE=
	set GOPROXY=https://proxy.golang.org,direct
	set GOROOT=C:\Program Files\go
	set GOSUMDB=sum.golang.org
	set GOTMPDIR=
	set GOTOOLDIR=C:\Program Files\go\pkg\tool\windows_amd64
	set GOVCS=
	set GOVERSION=go1.16.4
	set GCCGO=gccgo
	set AR=ar
	set CC=gcc
	set CXX=g++
	set CGO_ENABLED=1
	set GOMOD=c:\Users\ICH\Documents\_dev\cloud\go-printpixel\go.mod
	set CGO_CFLAGS=-g -O2
	set CGO_CPPFLAGS=
	set CGO_CXXFLAGS=-g -O2
	set CGO_FFLAGS=-g -O2
	set CGO_LDFLAGS=-g -O2
	set PKG_CONFIG=pkg-config
	set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ICH\AppData\Local\Temp\go-build1040132361=/tmp/go-build -gno-record-gcc-switches

Describe the bug

I opened my go project folder with VSCode (was not running before) and got greeted by this error message:

Error loading workspace: err: exit status 2: stderr: runtime: goroutine stack exceeds 1000000000-byte limit runtime: sp=0xc023f81380 stack=[0xc023f80000, 0xc043f80000] fatal error: stack overflow  runtime stack: runtime.throw(0xa09404, 0xe)
	c:/go/src/runtime/panic.go:1117 +0x79 runtime.newstack()
	c:/go/src/runtime/stack.go:1069 +0x80d runtime.morestack()
	c:/go/src/runtime/asm_amd64.s:458 +0x97  goroutine 1 [running]: fmt.(*fmt).pad(0xc000030520, 0xc000030585, 0x7, 0x7)
	c:/go/src/fmt/format.go:90 +0x354 fp=0xc023f81390 sp=0xc023f81388 pc=0x4aeab4 fmt.(*fmt).fmtInteger(0xc000030520, 0x17d04d, 0xa, 0x6400000001, 0xa0aa88, 0x11)
	c:/go/src/fmt/format.go:319 +0x1fa fp=0xc023f813d8 sp=0xc023f81390 pc=0x4af47a fmt.(*pp).fmtInteger(0xc0000304e0, 0x17d04d, 0x6400000001)
	c:/go/src/fmt/print.go:379 +0x206 fp=0xc023f81418 sp=0xc023f813d8 pc=0x4b2a66 fmt.(*pp).printArg(0xc0000304e0, 0x951700, 0xc0480afc10, 0x64)
	c:/go/src/fmt/print.go:672 +0x94b fp=0xc023f814b0 sp=0xc023f81418 pc=0x4b564b fmt.(*pp).doPrintf(0xc0000304e0, 0xa0343a, 0x5, 0xc023f81630, 0x1, 0x1)
	c:/go/src/fmt/print.go:1122 +0x3fc fp=0xc023f815a0 sp=0xc023f814b0 pc=0x4b88bc fmt.Sprintf(0xa0343a, 0x5, 0xc023f81630, 0x1, 0x1, 0xc0480e01c0, 0xc023f81668)
	c:/go/src/fmt/print.go:219 +0x6d fp=0xc023f815f8 sp=0xc023f815a0 pc=0x4b17cd cmd/go/internal/work.(*Builder).NewObjdir(0xc000076000, 0xc0480e01fb, 0xe)
	c:/go/src/cmd/go/internal/work/action.go:328 +0x91 fp=0xc023f81670 sp=0xc023f815f8 pc=0x867c51 cmd/go/internal/work.(*Builder).CompileAction.func1(0x96d7c0)
	c:/go/src/cmd/go/internal/work/action.go:409 +0x5a fp=0xc023f81708 sp=0xc023f81670 pc=0x8ae11a cmd/go/internal/work.(*Builder).cacheAction(0xc000076000, 0xa03458, 0x5, 0xc0003b4c00, 0xc023f81798, 0x0)
	c:/go/src/cmd/go/internal/work/action.go:371 +0xa5 fp=0xc023f81758 sp=0xc023f81708 pc=0x868585 cmd/go/internal/work.(*Builder).CompileAction(0xc000076000, 0x1, 0x1, 0xc0003b4c00, 0x8b6925)
	c:/go/src/cmd/go/internal/work/action.go:404 +0xe5 fp=0xc023f817c8 sp=0xc023f81758 pc=0x8687e5 cmd/go/internal/work.(*Builder).CompileAction.func1(0x96d7c0)
	c:/go/src/cmd/go/internal/work/action.go:414 +0x168 fp=0xc023f81860 sp=0xc023f817c8 pc=0x8ae228 cmd/go/internal/work.(*Builder).cacheAction(0xc000076000, 0xa03458, 0x5, 0xc0003b5180, 0xc023f818f0, 0x0)
	c:/go/src/cmd/go/internal/work/action.go:371 +0xa5 fp=0xc023f818b0 sp=0xc023f81860 pc=0x868585 cmd/go/internal/work.(*Builder).CompileAction(0xc000076000, 0x1, 0x1, 0xc0003b5180, 0x8b6925)
	c:/go/src/cmd/go/internal/work/action.go:404 +0xe5 fp=0xc023f81920 sp=0xc023f818b0 pc=0x8687e5 cmd/go/internal/work.(*Builder).CompileAction.func1(0x96d7c0)
	c:/go/src/cmd/go/internal/work/action.go:414 +0x168 fp=0xc023f819b8 sp=0xc023f81920 pc=0x8ae228 cmd/go/internal/work.(*Builder).cacheAction(0xc000076000, 0xa03458, 0x5, 0xc0003b4c00, 0xc023f81a48, 0x0)
	c:/go/src/cmd/go/internal/work/action.go:371 +0xa5 fp=0xc023f81a08 sp=0xc023f819b8 pc=0x868585 cmd/go/internal/work.(*Builder).CompileAction(0xc000076000, 0x1, 0x1, 0xc0003b4c00, 0x8b6925)
	c:/go/src/cmd/go/internal/work/action.go:404 +0xe5 fp=0xc023f81a78 sp=0xc023f81a08 pc=0x8687e5 cmd/go/internal/work.(*Builder).CompileAction.func1(0x96d7c0)
[... more of the same ...]
	c:/go/src/cmd/go/internal/work/action.go:414 +0x168 fp=0xc023f83f58 sp=0xc023f83ec0 pc=0x8ae228 cmd/go/internal/work.(*Builder).cacheAction(0xc000076000, 0xa03458, 0x5, 0xc0003b4c00, 0xc023f83fe8, 0x0)
	c:/go/src/cmd/go/internal/work/action.go:371 +0xa5 fp=0xc023f83fa8 sp=0xc023f83f58 pc=0x868585 cmd/go/internal/work.(*Builder).CompileAction(0xc000076000, 0x1, 0x1, 0xc0003b4c00, 0x8b6925)
	c:/go/src/cmd/go/internal/work/action.go:404 +0xe5 fp=0xc023f84018 sp=0xc023f83fa8 pc=0x8687e5 ...additional frames elided... : packages.Load error

The "Problems" tab revealed more info:

{
	"resource": "/C:/Users/ICH/Temp/example/go.mod",
	"owner": "_generated_diagnostic_collection_name_#1",
	"severity": 8,
	"message": <same as above>
	"source": "go list",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 21
}

Since the error seems to happen go.mod but it is not actually related.

module doesnotmatter

go 1.16

From my understanding this error happens when to conditions are met.

  1. Two packages form an import cycle
  2. One of those packages has a file with a mismatched package name

You can find a minimal example in the attached zip file.
example.zip

I would expect the project to load without an error ; )

Steps to reproduce the behavior:

  1. Go to 'File' > 'Open Folder...'
  2. Open the example folder from the extracted zip. example.zip
  3. See error in the status bar

Screenshots or recordings

Error in the status bar
image

@gopherbot gopherbot added this to the Untriaged milestone May 7, 2021
@hyangah
Copy link
Contributor

hyangah commented May 7, 2021

Looks like a duplicate of golang/go#25830.
go 1.17 will address this, and I don't know if gopls has a plan to backport or build a hack to handle older go versions.

cc @stamblerre

@hyangah
Copy link
Contributor

hyangah commented Aug 2, 2021

Fixes to be released

golang/go#25830 1.17
golang/go#47348 1.16.7
golang/go#47347 1.15.15

@stamblerre stamblerre removed their assignment Aug 6, 2021
@hyangah
Copy link
Contributor

hyangah commented Aug 10, 2021

1.16.7 and 1.15.15 were released. Closing.

@hyangah hyangah closed this as completed Aug 10, 2021
@golang golang locked and limited conversation to collaborators Aug 10, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants