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: panic because no snapshot assigned for files #42890

Closed
dgallion1 opened this issue Nov 30, 2020 · 7 comments
Closed

x/tools/gopls: panic because no snapshot assigned for files #42890

dgallion1 opened this issue Nov 30, 2020 · 7 comments

Comments

@dgallion1
Copy link

@dgallion1 dgallion1 commented Nov 30, 2020

gopls version: v0.5.3
gopls flags: -rpc.trace

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

panic: no snapshot assigned for files [file:///C:/work1/dev/server/goMods/dirReplicator/structs.go file:///C:/work1/dev/server/goMods/pkgInterface/pkgCtx.go file:///C:/work1/dev/server/goMods/pullPrinters/jobColumns.go file:///C:/work1/dev/server/goMods/pullPrinters/machineColumns.go file:///C:/work1/dev/server/goMods/pullPrinters/modi.go file:///C:/work1/dev/server/goMods/qc/qcRec.go file:///C:/work1/dev/server/goMods/dirReplicator/replicator.go file:///C:/work1/dev/server/goMods/jobServerLib/createTestJob.go file:///C:/work1/dev/server/goMods/qc/init.go file:///C:/work1/dev/server/goMods/dirReplicator/watcher.go file:///C:/work1/dev/server/goMods/pullPrinters/genXlsx.go file:///C:/work1/dev/server/goMods/csvData/database.go file:///C:/work1/dev/server/goMods/jobServerLib/announce.go file:///C:/work1/dev/server/goMods/jobServerLib/generated.go file:///C:/work1/dev/server/goMods/jobServerLib/jobHandlers.go file:///C:/work1/dev/server/goMods/jobServerLib/models_gen.go file:///C:/work1/dev/server/goMods/jobServerLib/myResolvers.go file:///C:/work1/dev/server/goMods/jobServerLib/resolver.go file:///C:/work1/dev/server/goMods/jobServerLib/top.go file:///C:/work1/dev/server/goMods/qc/handler.go file:///C:/work1/dev/server/goMods/pullPrinters/net.go]

goroutine 3772 [running]:
golang.org/x/tools/internal/lsp.(*Server).didModifyFiles(0xc0002a4000, 0xd51880, 0xc0049d4c00, 0xc013a43500, 0x19, 0x21, 0x2, 0x0, 0x0)
	  text_synchronization.go:234  0xe8b
golang.org/x/tools/internal/lsp.(*Server).didChangeWatchedFiles(0xc0002a4000, 0xd51880, 0xc0049d4c00, 0xc001ea3160, 0x0, 0xc000db82c0)
	  text_synchronization.go:142  0x20f
golang.org/x/tools/internal/lsp.(*Server).DidChangeWatchedFiles(0xc0002a4000, 0xd51880, 0xc0049d4c00, 0xc001ea3160, 0xc001ea3160, 0x0)
	  server_gen.go:44  0x50
golang.org/x/tools/internal/lsp/protocol.serverDispatch(0xd51880, 0xc0049d4c00, 0xd66100, 0xc0002a4000, 0xc00e2fc720, 0x2bdbaff7ec0, 0xc0049d4ba0, 0x0, 0xd3f060, 0xc00151f970)
	  tsserver.go:147  0x4fa7
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0xd51880, 0xc0049d4c00, 0xc00e2fc720, 0x2bdbaff7ec0, 0xc0049d4ba0, 0x47046471d, 0x11aac80)
	  protocol.go:63  0xc7
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0xd51880, 0xc0049d4c00, 0xc00e2fc720, 0x2bdbaff7ec0, 0xc0049d4ba0, 0x0, 0x0)
	  lsprpc.go:559  0x452
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1(0xd51880, 0xc0049d4c00, 0xc0062df1a0, 0x2bdbaff7ec0, 0xc0049d4ba0, 0xc000c8cdd0, 0xd)
	  handler.go:35  0xda
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc00553b6e0, 0xc0049d5680, 0xc0009260d0, 0xd51880, 0xc0049d4c00, 0xc0062df1a0, 0x2bdbaff7ec0, 0xc0049d4ba0)
	  handler.go:103  0x8d
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x179
[Error - 12:10:38 PM] 

OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

<OPTIONAL: ATTACH LOGS HERE>

@stamblerre stamblerre transferred this issue from golang/vscode-go Nov 30, 2020
@stamblerre stamblerre changed the title gopls: automated issue report (crash) x/tools/gopls: automated issue report (crash) Nov 30, 2020
@gopherbot gopherbot added this to the Unreleased milestone Nov 30, 2020
@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default via automation Nov 30, 2020
@heschi
Copy link
Contributor

@heschi heschi commented Nov 30, 2020

Staring at the code for a while, I believe this happens when viewOf returns a view for which relevantChange is false. We are then somewhat trapped: the generated file check wants a view to be assigned, but there's no new snapshot to diagnose. I'm not sure enough of the details to build a repro easily.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 30, 2020

This looks like the check later on text_synchronization.go:234, which I would've guessed would be addressed by this check in (*session).DidModifyFiles. I'll continue investigating.

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 1, 2020

Change https://golang.org/cl/274235 mentions this issue: internal/lsp: return snapshots instead of views from DidModifyFiles

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 3, 2020

@dgallion1: Would you be able to share the workspace set-up that led to you encountering this issue? We have some guesses about how to mitigate the issue, but it would be best if we could reproduce it. A log would also be helpful: https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs.

@stamblerre stamblerre moved this from Needs Triage to Waiting for Info in vscode-go: gopls by default Dec 3, 2020
@stamblerre stamblerre changed the title x/tools/gopls: automated issue report (crash) x/tools/gopls: panic because no snapshot assigned for files Dec 3, 2020
@dgallion1
Copy link
Author

@dgallion1 dgallion1 commented Dec 3, 2020

Added: "go.languageServerFlags": [ "-rpc.trace" ],
The original workspace is gone. I removed directories in an effort to keep gopls working.
It stops constantly throughout the day.
We use HG but the npm directories all init with GIT
Here's a workspace that's close:
{
"folders": [
{
"path": "dev\server\goMods\util"
},
{
"path": "dev\server\goMods\DMM"
},
{
"path": "dev\webServer\npm"
},
{
"path": "dev\server\goMods\jobServer\slicerQ"
},
{
"path": "dev\server\goMods\jobServer"
},
{
"path": "dev\server\goMods" <<<--- There are many go.mod directories below this.
}
],
"settings": {
"python.pythonPath": "C:\Anaconda3\python.exe"
}
}

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Dec 6, 2020

Thank you for explaining the details of the workspace, but it's still difficult to reproduce the problem without a log. Would you be able to provide one if you encounter this again? (https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs)

In the meantime, I believe https://golang.org/cl/274235 will address the panic you encountered.

@dgallion1
Copy link
Author

@dgallion1 dgallion1 commented Dec 6, 2020

Added: "go.languageServerFlags": [ "-rpc.trace" ]
So next time I see a panic there will be logs and I'll make the effort to send them.

vscode-go: gopls by default automation moved this from Waiting for Info to Done Dec 8, 2020
marwan-at-work added a commit to marwan-at-work/tools that referenced this issue Dec 23, 2020
For every file change, we want to diagnose the resulting snapshots.
However, we also want to diagnose the file in its "best possible" view
(for example, for a nested module, we should use the inner module rather
than the outer module).

Add a bestView function that operates on a set of views, which allows
us to a pick a view out of the *views affected* by a file modification,
not out of *all* of the views in the session. This means that we can
pick the best view, if any, for each file change and then only return
the snapshots that we should diagnose, as well as the changed URIs for
those snapshots.

Fixes golang/go#42890

Change-Id: Iad23d5ed4832dfd857f1424a7244cf3bd8900e3b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/274235
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants