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: race to ModuleResolver.moduleCacheCache #49396

Open
davecheney opened this issue Oct 31, 2021 · 1 comment
Open

x/tools/gopls: race to ModuleResolver.moduleCacheCache #49396

davecheney opened this issue Oct 31, 2021 · 1 comment
Assignees
Milestone

Comments

@davecheney
Copy link
Contributor

@davecheney davecheney commented Oct 31, 2021

gopls version: v0.7.3
gopls flags:
update flags: proxy
extension version: 0.29.0
go version: devel go1.18-d032b2b2c8
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Sun, 31 Oct 2021 22:55:38 GMT
restart history:
Fri, 29 Oct 2021 12:19:24 GMT: activation (enabled: false)
Sun, 31 Oct 2021 22:31:02 GMT: installation (enabled: true)
Sun, 31 Oct 2021 22:33:56 GMT: installation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

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

goroutine 7181 [running]:
golang.org/x/tools/internal/imports.(*dirInfoCache).Load(0xa8cba40%3F, {0xc0046de000%3F, 0xc004889f10%3F})
	  mod_cache.go:184  0x62
golang.org/x/tools/internal/imports.(*ModuleResolver).cacheLoad(0xc0002b2780, {0xc0046de000, 0x3e})
	  mod.go:273  0xa6
golang.org/x/tools/internal/imports.(*ModuleResolver).findPackage(0xc0002b2780, {0xc00030eea0, 0x10})
	  mod.go:235  0x1f1
golang.org/x/tools/internal/imports.(*ModuleResolver).scoreImportPath(0x0%3F, {0x0%3F, 0x0%3F}, {0xc00030eea0, 0x10})
	  mod.go:512  0x6a
golang.org/x/tools/internal/imports.ScoreImportPaths({0x1b8e288, 0xc006f74000}, 0xc00488a360%3F, {0xc00785a000, 0xa, 0x18f6560%3F})
	  fix.go:670  0xef
golang.org/x/tools/internal/lsp/source/completion.(*completer).unimportedPackages.func1(0x180d9a0%3F)
	  completion.go:1441  0x3f
golang.org/x/tools/internal/lsp/cache.(*importsState).runProcessEnvFunc(0xc0005ed320, {0x1b8e288, 0xc006f74000}, 0xc002cc0900, 0xc00469c210)
	  imports.go:109  0x5a3
golang.org/x/tools/internal/lsp/cache.(*snapshot).RunProcessEnvFunc(0xc00488a728%3F, {0x1b8e288%3F, 0xc006f74000%3F}, 0x400%3F)
	  view.go:332  0x34
golang.org/x/tools/internal/lsp/source/completion.(*completer).unimportedPackages(0xc000160a00, {0x1b8e288, 0xc006f74000}, 0xc00469c0f0)
	  completion.go:1439  0x47c
golang.org/x/tools/internal/lsp/source/completion.(*completer).lexical(0xc000160a00, {0x1b8e288, 0xc006f74000})
	  completion.go:1371  0x749
golang.org/x/tools/internal/lsp/source/completion.(*completer).collectCompletions(0xc000160a00, {0x1b8e288%3F, 0xc006f74000%3F})
	  completion.go:626  0x3d4
golang.org/x/tools/internal/lsp/source/completion.Completion({0x1b8e218%3F, 0xc00242c680%3F}, {0x1b95990%3F, 0xc002cc0900%3F}, {0x1b8ec50%3F, 0xc004442180%3F}, {0x2b8f328%3F, 0xc0%3F}, {0x3ff0000000000000, {0x0, ...}})
	  completion.go:551  0xfe9
golang.org/x/tools/internal/lsp.(*Server).completion(0xc006a7e9b8%3F, {0x1b8e218, 0xc00242c680}, 0xc005384cd0)
	  completion.go:32  0x24c
golang.org/x/tools/internal/lsp.(*Server).Completion(0xc002c6c9a0%3F, {0x1b8e218%3F, 0xc00242c680%3F}, 0x17f9d60%3F)
	  server_gen.go:32  0x25
golang.org/x/tools/internal/lsp/protocol.serverDispatch({0x1b8e218, 0xc00242c680}, {0x1b98be0, 0xc000288240}, 0xc0039e20f0, {0x1b8e480, 0xc00242c600})
	  tsserver.go:382  0x18dd
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1({0x1b8e218, 0xc00242c680}, 0xc0039e20f0, {0x1b8e480, 0xc00242c600})
	  protocol.go:154  0x90
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1({0x1b8e218, 0xc00242c680}, 0xc0039e20f0, {0x1b8e480%3F, 0xc00242c600%3F})
	  lsprpc.go:506  0xa43
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x1b8e218, 0xc00242c680}, 0xc003178978, {0x1b8e480%3F, 0xc00242c600%3F})
	  handler.go:35  0xf6
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2()
	  handler.go:103  0xa3
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x20a
[Error - 9:40:47 AM] 

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>

@findleyr
Copy link
Contributor

@findleyr findleyr commented Nov 1, 2021

This is a bug (a race) in x/tools.

Notes:

  • looks like it's possible to reach the ModuleResolver.moduleCacheCache before initialization.
  • from discussion with @heschi, it might be OK to eagerly initialize in ProcessEnv.GetResolver: presumably by the time we get the resolver we actually need it. There may be edge cases, however.

Loading

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: race to ModuleResolver.moduleCacheCache Nov 5, 2021
@findleyr findleyr transferred this issue from golang/vscode-go Nov 5, 2021
@findleyr findleyr added the gopls label Nov 5, 2021
@findleyr findleyr added this to the gopls/on-deck milestone Nov 5, 2021
@gopherbot gopherbot added the Tools label Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants