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: automated issue report (crash) #3287

Closed maoueh closed 3 months ago

maoueh commented 3 months ago

Metadara

gopls version: v0.15.2/go1.22.0 gopls flags: update flags: proxy extension version: 0.41.2 environment: Visual Studio Code darwin initialization error: undefined issue timestamp: Wed, 27 Mar 2024 20:23:57 GMT restart history: Tue, 26 Mar 2024 14:31:34 GMT: activation (enabled: true)

Describe what you observed.

I was playing with git changing branches and doing rebase while it happened. Return to vscode just to see the popup to report a problem online.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x88 pc=0x1034be510]

goroutine 117252 [running]:
golang.org/x/tools/internal/imports.(*ProcessEnv).ClearModuleInfo(0x1400011ee10)
      mod.go:318  0x60
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc(0x140004503c0, {0x103d0c6e8%3F, 0x1400c2806f0%3F}, 0x14009f58c60, 0x1400d07ede8)
      imports.go:164  0x22c
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc(...)
      view.go:439
golang.org/x/tools/gopls/internal/golang.allImportsFixes({0x103d0c6e8%3F, 0x1401114d560%3F}, 0x14009f58c60, 0x14024ae8000)
      format.go:118  0xc8
golang.org/x/tools/gopls/internal/golang.CodeActions({0x103d0c6e8, 0x1401114d560}, 0x14009f58c60, {0x103d0d9c0, 0x1400b327560}, {{0x9f58c60%3F, 0x140%3F}, {0x43acac0%3F, 0x1%3F}}, {0x1043acac0, ...}, ...)
      codeaction.go:44  0x194
golang.org/x/tools/gopls/internal/server.(*server).CodeAction(0x1400012a000, {0x103d0c720%3F, 0x1401c4e4460%3F}, 0x14012ad45b0)
      code_action.go:117  0x4f0
golang.org/x/tools/gopls/internal/protocol.serverDispatch({0x103d0c720, 0x1401c4e4460}, {0x103d25c20, 0x1400012a000}, 0x1401114d4a0, {0x103d0c8e0, 0x1401376ab00})
      tsserver.go:256  0x1dc8
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3({0x103d0c720, 0x1401c4e4460}, 0x1401114d4a0, {0x103d0c8e0, 0x1401376ab00})
      protocol.go:160  0x74
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4({0x103d0c720, 0x1401c4e4460}, 0x1401114d4a0, {0x103d0c8e0, 0x1401376ab00})
      lsprpc.go:509  0x6e0
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1({0x103d0c720, 0x1401c4e4460}, 0x14005b51b48, {0x103d0c8e0, 0x1401376ab00})
      handler.go:35  0xc0
golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2.2()
      handler.go:103  0x90
created by golang.org/x/tools/gopls/internal/protocol.Handlers.AsyncHandler.func2 in goroutine 78
      handler.go:100  0x19c
gopls stats -anon gopls stats -anon failed after 60014 ms. Please check if gopls is killed by OS.

gopls stats -anon

Here the output when run manually in the same folder that I was working with as the base workspace. Took 1m 43s to run:

<details><summary>gopls stats -anon (manually run)</summary> 
Initializing workspace...     done (6.618037458s)
Gathering bug reports...      done (1m36.388576584s)
Querying memstats...          done (44.611916ms)
Querying workspace stats...   done (5.284209ms)
Collecting directory info...  done (461.360209ms)
{
  "DirStats": {
    "Files": 33397,
    "TestdataFiles": 88,
    "GoFiles": 3020,
    "ModFiles": 5,
    "Dirs": 4906
  },
  "GOARCH": "arm64",
  "GOOS": "darwin",
  "GOPACKAGESDRIVER": "",
  "GOPLSCACHE": "",
  "GoVersion": "go1.22.0",
  "GoplsVersion": "v0.15.2",
  "InitialWorkspaceLoadDuration": "6.618037458s",
  "MemStats": {
    "HeapAlloc": 275148352,
    "HeapInUse": 347185152,
    "TotalAlloc": 1676688136
  },
  "WorkspaceStats": {
    "Files": {
      "Total": 6636,
      "Largest": 14630390,
      "Errs": 0
    },
    "Views": [
      {
        "GoCommandVersion": "go1.22.0",
        "AllPackages": {
          "Packages": 1520,
          "LargestPackage": 155,
          "CompiledGoFiles": 6993,
          "Modules": 173
        },
        "WorkspacePackages": {
          "Packages": 216,
          "LargestPackage": 47,
          "CompiledGoFiles": 967,
          "Modules": 1
        },
        "Diagnostics": 0
      }
    ]
  }
}
</details>

gopls logs (Or what I think is gopls logs)

Let me know if it's not the case: gopls-logs-at-least-what-I-think-is-gopls-logs.log

suzmue commented 3 months ago

Thanks for filing this issue! Looks like this is the same as this upstream issue https://github.com/golang/go/issues/66490, which has a fix in and will be fixed in the next release.