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) #3452

Closed Kristianwhittick closed 1 month ago

Kristianwhittick 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: Mon, 15 Jul 2024 10:35:15 GMT restart history: Mon, 15 Jul 2024 10:34:46 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

In VSCode, I changed the folder from an existing go project to a different existing go project. A few seconds later the gopls server crashed.

panic:   stmt.go:932: assertion failed

goroutine 900 [running]:
go/types.(*Checker).handleBailout(0xc00120ae00, 0xc00156b898)
      check.go:367  0x88
panic({0xe9b560%3F, 0xc000bf93e0%3F})
      panic.go:770  0x132
go/types.assert(0x0%3F)
      errors.go:28  0x54
go/types.(*Checker).rangeStmt(0xc00120ae00, 0x3, 0xc00040fda0)
      stmt.go:932  0xe70
go/types.(*Checker).stmt(0xc00120ae00, 0x3, {0x1319688, 0xc00040fda0})
      stmt.go:827  0xab9
go/types.(*Checker).stmtList(0xc00120ae00, 0x3, {0xc0009c7050%3F, 0x1018987%3F, 0x5%3F})
      stmt.go:121  0x85
go/types.(*Checker).stmt(0xc00120ae00, 0x3, {0x1319628, 0xc000f18e70})
      stmt.go:562  0x20f2
go/types.(*Checker).rangeStmt(0xc00120ae00, 0x3, 0xc00040fe00)
      stmt.go:993  0x74d
go/types.(*Checker).stmt(0xc00120ae00, 0x0, {0x1319688, 0xc00040fe00})
      stmt.go:827  0xab9
go/types.(*Checker).stmtList(0xc00120ae00, 0x0, {0xc000364900%3F, 0x0%3F, 0x0%3F})
      stmt.go:121  0x85
go/types.(*Checker).funcBody(0xc00120ae00, 0x1315b10%3F, {0xc000887264%3F, 0x19acaa0%3F}, 0xc00038e440, 0xc000f18ea0, {0x0%3F, 0x0%3F})
      stmt.go:41  0x331
go/types.(*Checker).funcDecl.func1()
      decl.go:852  0x3a
go/types.(*Checker).processDelayed(0xc00120ae00, 0x0)
      check.go:467  0x162
go/types.(*Checker).checkFiles(0xc00120ae00, {0xc000a8e6e8, 0x1, 0x1})
      check.go:411  0x1cc
go/types.(*Checker).Files(...)
      check.go:372
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).checkPackage(0xc001558a20, {0x131aa28, 0xc001079770}, 0xc001030900)
      check.go:1543  0xa25
golang.org/x/tools/gopls/internal/cache.(*typeCheckBatch).handleSyntaxPackage(0xc001558a20, {0x131aa28, 0xc001079770}, 0x0, {0xc0005281e0, 0x9})
      check.go:568  0x5e5
golang.org/x/tools/gopls/internal/cache.(*Snapshot).forEachPackageInternal.func2()
      check.go:418  0x2b
golang.org/x/sync/errgroup.(*Group).Go.func1()
      errgroup.go:78  0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 802
      errgroup.go:75  0x96
gopls stats -anon gopls stats -anon failed after 2301 ms. Please check if gopls is killed by OS.

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.

hyangah commented 1 month ago

Thanks for the report. @Kristianwhittick

Can you please tell us more what you meant by "changing the folder from a project to a different project"? Did you use "File: Open Folder" command, after closing the current folder?

If you restart the vscode with the second project ("Developer: Reload Window" command), does gopls crash again? If it crashes, given that the stack trace exactly matches, I think it is a duplicate of https://github.com/golang/go/issues/68334. The fix requires new Go release. (go1.23 or a new patch release of go1.22 which is in progress)

Kristianwhittick commented 1 month ago

Yes, I used "File: Open Folder" but "not" after closing the current folder. I still had the old folder open when I selected the new location.

I will upgrade the version and see if this happens again.

findleyr commented 1 month ago

Closing as a duplicate of golang/go#68334, so this should be fixed in Go 1.22.6.