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

x/tools/gopls: crash in PackageStats #40224

csides opened this issue Jul 15, 2020 · 6 comments

x/tools/gopls: crash in PackageStats #40224

csides opened this issue Jul 15, 2020 · 6 comments


Copy link

@csides csides commented Jul 15, 2020


Describe what you observed:

Go language server (gopls) restarts several times and crashes most of them. Occasionally it will stay alive for a few minutes (before crashing again).

Please attach the stack trace from the crash.
A window with the error message should have popped up in the lower half of your screen.
Please copy the stack trace from that window and paste it in this issue.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x110af99]

goroutine 92 [running]:
go/ast.Walk(0x1a94da0, 0xc01b8d1e80, 0x1a98f60, 0x0)
	/Users/sides/code/impira/opt/go/src/go/ast/walk.go:349 +0x25f9
	/Users/sides/code/impira/opt/go/src/go/ast/walk.go:385, 0x17cb5e0)
	/Users/sides/code/go_tools/pkg/mod/ +0x97*Cache).PackageStats.func1(0x17f2480, 0xc0002d9150, 0x17cb420, 0xc007aaaee0)
	/Users/sides/code/go_tools/pkg/mod/ +0x21b*Store).DebugOnlyIterate(0xc0002e9520, 0xc04fc485b0)
	/Users/sides/code/go_tools/pkg/mod/ +0x176*Cache).PackageStats(0xc0002e9500, 0xc037261f01, 0xc, 0x1a93600)
	/Users/sides/code/go_tools/pkg/mod/ +0x94*Instance).writeMemoryDebug(0xc0002fe000, 0x1, 0x1, 0x0, 0x0)
	/Users/sides/code/go_tools/pkg/mod/ +0x5df*Instance).MonitorMemory.func1(0xc00022cfa0, 0xc0002ca570, 0xc0002fe000, 0x1aa7e20, 0xc0002e5380)
	/Users/sides/code/go_tools/pkg/mod/ +0xb6
created by*Instance).MonitorMemory
	/Users/sides/code/go_tools/pkg/mod/ +0x99
[Error - 8:55:20 PM] Connection to server got closed. Server will not be restarted.

Additional Information:

I believe this issue is related to PackageStats. I was poking around on the debug site mentioned here (localhost:6060)

When I loaded the cache tab [ http://localhost:6060/cache/1 ] (as the segfault seems to be on a cache access above):
The page had the follow text
Cache 1

memoize.Store entries
cache.actionHandleKey - 31
cache.packageHandleKey - 891
cache.parseKey - 4042
source.FileIdentity - 1

Per-package usage - not accurate, for guidance only
template: :7:2: executing "body" at <.PackageStats>: error calling PackageStats: runtime error: invalid memory address or nil pointer dereference

  1. There's no chance this can come from the codebase I'm working on, correct? This does not seem to be related to any changes made in our repo, and reverting pretty far back in time does not fix the issue.

  2. I can provide more information if needed, but I would have to redact some pieces, so please let me know what is helpful! I tend to use moderately basic features (autocomplete, go to def/type/impl), so if there are portions of the Go extension that I can disable entirely, that might also serve as a good workaround. Thanks!

Screen Shot 2020-07-14 at 9 03 38 PM

Copy link

@stamblerre stamblerre commented Jul 15, 2020

Thanks for the detailed report! To confirm, this is with gopls/v0.4.3, right? (gopls version to check.)

@heschik: Looks like this is crashing in the call to ast.Inspect. I guess we need a case to handle a nil file.

@stamblerre stamblerre transferred this issue from golang/vscode-go Jul 15, 2020
@stamblerre stamblerre changed the title gopls: automated issue report (crash) -- SegFault (SIGSEGV: segmentation violation) x/tools/gopls: crash in PackageStats Jul 15, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jul 15, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.4 Jul 15, 2020
Copy link

@csides csides commented Jul 15, 2020

Yup! I've updated (and reinstalled the entire extension) several times to verify.

[Info  - 9:51:06 PM] 2020/07/14 21:51:06 Build info
---------- 0.4.3 h1:irz7Q+XdHNECamFKbNWKvMV2Ak6zBbwdwbZndG4545I= h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= h1:Vc0Vx98oU/O3+qPQ36fnTT5UduS55KLh2uSGbL7mqEo= h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info
go version go1.13 darwin/amd64
Copy link

@gopherbot gopherbot commented Jul 15, 2020

Change mentions this issue: internal/lsp: handle nil pointer in PackageStats

Copy link

@csides csides commented Jul 16, 2020

Should I be waiting for a minor version update to gopls? @stamblerre

Copy link

@stamblerre stamblerre commented Jul 16, 2020

You can try it out now by installing gopls at master: GO111MODULE=on go get I have to admit, I am surprised you are encountering this frequently, as it's really a corner case. Let us know if the latest version fixes it.

Copy link

@csides csides commented Jul 16, 2020

I've been working with them for a few hours now. Seems to be working perfectly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants