Skip to content

x/tools/gopls: snapshot leak via view.importsState #53780

@findleyr

Description

@findleyr

Discovered while investigating #50707: When we create a processEnv for running goimports, we acquire the snapshot: https://cs.opensource.google/go/x/tools/+/master:internal/lsp/cache/imports.go;l=146;drc=53ead67a981c04bcacdd4f593330c43ee9285578

But the process env is associated with the view, and so this snapshot is not released until the imports state is invalidated (which can be the entire editing session).

As a result, we hold on to whichever snapshot was used to create the process env. As time passes the data referenced by this snapshot becomes staler and staler, and is increasingly duplicated. In brief testing this leak seemed significant.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions