golang / vscode-go

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

gopls: automated issue report (crash) #3456

Closed feldgendler closed 1 month ago

feldgendler commented 1 month ago

gopls version: v0.16.1/go1.22.5 gopls flags: update flags: proxy extension version: 0.41.4 environment: Visual Studio Code linux initialization error: undefined issue timestamp: Wed, 17 Jul 2024 14:01:22 GMT restart history: Wed, 17 Jul 2024 13:58:52 GMT: activation (enabled: true)

gopls crashes repeatably while the editor is idle.

panic: runtime error: slice bounds out of range [73:72]

goroutine 8394 [running]:
golang.org/x/tools/internal/imports.(*ModuleResolver).scanDirForPackage(0xc001576370, {{0xc000016000%3F, 0xc000081008%3F}, 0x9c136ac15b2de0c3%3F}, {0xc001f8bbc0, 0x48})
      mod.go:744  0x6ff
golang.org/x/tools/internal/imports.(*ModuleResolver).scan.func3({{0xc000016000%3F, 0xe9b560%3F}, 0xc004e6a1d0%3F}, {0xc001f8bbc0%3F, 0x196f368%3F})
      mod.go:618  0x50
golang.org/x/tools/internal/gopathwalk.(*walker).walk(0xc002d19200, {0xc001f8bbc0, 0x58}, 0x0, {0x131ab98, 0xc002f58d40})
      walk.go:268  0x3f7
golang.org/x/tools/internal/gopathwalk.(*walker).walk(0xc002d19200, {0xc000522140, 0x48}, 0x0, {0x131ab98, 0xc002f58c80})
      walk.go:334  0x886
golang.org/x/tools/internal/gopathwalk.(*walker).walk(0xc002d19200, {0xc00590e280, 0x39}, 0x0, {0x131ab98, 0xc001fb6d40})
      walk.go:334  0x886
golang.org/x/tools/internal/gopathwalk.(*walker).walk.func1()
      walk.go:325  0x65
created by golang.org/x/tools/internal/gopathwalk.(*walker).walk in goroutine 8122
      walk.go:320  0x945
gopls stats -anon { "DirStats": { "Files": 58198, "TestdataFiles": 8053, "GoFiles": 25142, "ModFiles": 285, "Dirs": 9672 }, "GOARCH": "amd64", "GOOS": "linux", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.5", "GoplsVersion": "v0.16.1", "InitialWorkspaceLoadDuration": "1.017607264s", "MemStats": { "HeapAlloc": 24842568, "HeapInUse": 40026112, "TotalAlloc": 374969176 }, "WorkspaceStats": { "Files": { "Total": 1552, "Largest": 395026, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.5", "AllPackages": { "Packages": 233, "LargestPackage": 161, "CompiledGoFiles": 1560, "Modules": 30 }, "WorkspacePackages": { "Packages": 7, "LargestPackage": 19, "CompiledGoFiles": 37, "Modules": 1 }, "Diagnostics": 0 } ] } }

This happens after a period of UI inactivity. This precedes the crash in the log:

[Info  - 5:06:46 PM] 2024/07/17 17:06:46 background imports cache refresh starting
hyangah commented 1 month ago

Thanks for the report @feldgendler

Duplicate of https://github.com/golang/go/issues/67156 but this case does not involve Windows (and, thus hopefully not modified GOROOT)

findleyr commented 1 month ago

Let's close as a duplicate. With @feldgendler's help I believe we understand this crash now.