golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 728 forks source link

gopls: nil panic in ClearModuleInfo #3277

Closed juparefe closed 3 months ago

juparefe commented 3 months ago

gopls version: v0.15.2/go1.20.6 gopls flags: update flags: proxy extension version: 0.41.2 environment: Visual Studio Code darwin initialization error: undefined issue timestamp: Sun, 24 Mar 2024 15:55:27 GMT restart history: Fri, 22 Mar 2024 20:00:01 GMT: activation (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=0x88 pc=0x15c8787]

goroutine 830606 [running]:
golang.org/x/tools/internal/imports.(*ProcessEnv).ClearModuleInfo(0xc000522ea0)
      mod.go:318  0x67
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc(0xc0001de9b0, {0x1e50bd8%3F, 0xc0059a4600%3F}, 0xc005a36240, 0xc002940d68)
      imports.go:164  0x28c
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc(...)
      view.go:439
golang.org/x/tools/gopls/internal/golang.allImportsFixes({0x1e50bd8%3F, 0xc0059a4420%3F}, 0xc005a36240, 0xc000000690)
      format.go:118  0x12e
golang.org/x/tools/gopls/internal/golang.CodeActions({0x1e50bd8, 0xc0059a4420}, 0xc005a36240, {0x1e51d40, 0xc0051c60c0}, {{0x1a11940%3F, 0x0%3F}, {0x4c640c0%3F, 0xc0%3F}}, {0x24746c8, ...}, ...)
      codeaction.go:44  0x1ef
golang.org/x/tools/gopls/internal/server.(*server).CodeAction(0xc004f2e360%3F, {0x1e50b30%3F, 0xc0047442d0%3F}, 0xc004c64070)
      code_action.go:117  0x7da
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x1e50b30, 0xc0047442d0}, {0x1e632a0, 0xc000202100}, 0xc0059a4360, {0x1e50e40, 0xc005a32080})
      tsserver.go:256  0x2868
golang.org/x/tools/gopls/internal/protocol.ServerHandler.func1({0x1e50b30, 0xc0047442d0}, 0xc0059a4360, {0x1e50e40, 0xc005a32080})
      protocol.go:160  0x9a
golang.org/x/tools/gopls/internal/lsprpc.handshaker.func1({0x1e50b30, 0xc0047442d0}, 0xc0059a4360, {0x1e50e40%3F, 0xc005a32080%3F})
      lsprpc.go:509  0x9f9
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x1e50b30, 0xc0047442d0}, 0xc0035b2948, {0x1e50e40%3F, 0xc005a32080%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
gopls stats -anon { "DirStats": { "Files": 398, "TestdataFiles": 0, "GoFiles": 18, "ModFiles": 1, "Dirs": 212 }, "GOARCH": "amd64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.20.6", "GoplsVersion": "v0.15.2", "InitialWorkspaceLoadDuration": "614.491706ms", "MemStats": { "HeapAlloc": 21887104, "HeapInUse": 36249600, "TotalAlloc": 299026256 }, "WorkspaceStats": { "Files": { "Total": 1340, "Largest": 387703, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.20.6", "AllPackages": { "Packages": 233, "LargestPackage": 134, "CompiledGoFiles": 1336, "Modules": 18 }, "WorkspacePackages": { "Packages": 9, "LargestPackage": 6, "CompiledGoFiles": 18, "Modules": 1 }, "Diagnostics": 0 } ] } }
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.
suzmue commented 3 months ago

Looks like the same as upstream issue golang/go#66490, which is now fixed.