-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: crash importing test variant of tools file #66109
Comments
Thanks for the report. This looks like a dupe of golang/vscode-go#3207, and it's very interesting that the package ID in question is exactly the same. Are you by any chance a colleague of @amirrmonfared? I ask because if this isn't coming from the exact same code base, it's possible that there's something about the package layout of easyjson that exacerbates this bug. |
@painhardcore I should also ask: does this crash occur in an open source repository, from which we could try to reproduce? |
@findleyr Yep, his my colleague and has similar issue. Not sure about open source repo that we can match(we have vendored packages and easyjson)... 1.15.0 and 1.15.1 are affected and have same panic trace, but 1.14.2 works fine But so far I found a small trick to work
VScode will update the gopls anyway, but the current gopls instance wont be effected. So if I need other brach in a new window(I use git worktree) - I just downgrade it before opening new VScode. |
To be clear, downgrading is not a long-term solution. We need to fix this bug. I believe this problem is related to the use of a tools.go pattern, as is described here: "github.com/mailru/easyjson/easyjson" is a command, not an importable package (i.e. it is Can you search for this import in your codebase, and share details about the file containing the import? If possible, I would love to see the full header of the file with the import (the package name and imports, as well as any |
Yep, we have a file, that we keep to have everything in vendor. //go:build tools
// +build tools
// This file tracks toolings that aren't directly used by repo
// but they are required to build the project.
// Refer to https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
package back
import (
_ "github.com/mailru/easyjson/easyjson"
_ "github.com/quasilyte/go-ruleguard/dsl" // For .github/gorules/rules.go.
) I don't understand how its connected with _test.go files, but apparently something triggers background scan or smth: I can go and edit .go files and everything is OK. Until I go to _test.go file and do "go to definition" it's crashing. But if I remove that file with tools - it works OK, and crashes only when I bring it back. |
BTW the new link |
@findleyr and I found the issue, its because the file with these tools is called |
Thanks. For some reason I still can't reproduce, but this is enough information for me to put together a fix. Transferring to the gopls issue tracker. |
Change https://go.dev/cl/569035 mentions this issue: |
@findleyr reproducable repo https://github.com/painhardcore/goplscrash . Just go to tools/tools_test.go in VScode and gopls will crash. |
Indeed it does! Apparently the file must be in a nested directory. Thank you for the reproducer! |
Yep, in our case file tools_test.go was in root folder, so every test file in a big repo was like a trigger 😄 |
Change https://go.dev/cl/569437 mentions this issue: |
@painhardcore and @amirrmonfared, huge thanks for your conscientious help resolving this bug. The CL above should fix this crash. However, we have a couple other issues to sort out before we cut gopls@v0.15.2 with this fix. |
Thanks. |
…to command-line-arguments pkgs Fix two bugs discovered during the investigation of golang/go#66109, which revealed the strange and broken intermediate test variant form "path/to/command/package [command-line-arguments.test]", referenced from the equally broken "command-line-arguments [command-line-arguments.test]". This latter package was *also* detected as an ITV, which is why we never tried to type check it in gopls@v0.14.2. - Snapshot.orphanedFileDiagnostics was not pruning intermediate test variants, causing it to be the one place where we were now type checking ITVs. - Fix the latent bug that caused gopls to record a dangling edge between the two ITVs. There is a third bug in go/packages, filed as golang/go#66126. Fixes golang/go#66109 Change-Id: Ie5795b6d5a4831bf2f73217c8eb22c6ba18e59cd Reviewed-on: https://go-review.googlesource.com/c/tools/+/569035 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> (cherry picked from commit caf5940) Reviewed-on: https://go-review.googlesource.com/c/tools/+/569437 Auto-Submit: Robert Findley <rfindley@google.com>
Thanks a lot @findleyr for your support and thanks to @painhardcore for solving the issue in our repo ❤️ |
This fix is included in our prerelease:
|
gopls version: v0.15.1/go1.22.0
gopls flags:
update flags: proxy
extension version: 0.41.1
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Fri, 01 Mar 2024 00:31:32 GMT
restart history:
Fri, 01 Mar 2024 00:30:44 GMT: activation (enabled: true)
Crashing gopls
gopls stats -anon
{ "DirStats": { "Files": 8067, "TestdataFiles": 52, "GoFiles": 6683, "ModFiles": 4, "Dirs": 1348 }, "GOARCH": "arm64", "GOOS": "darwin", "GOPACKAGESDRIVER": "", "GOPLSCACHE": "", "GoVersion": "go1.22.0", "GoplsVersion": "v0.15.1", "InitialWorkspaceLoadDuration": "1.65849025s", "MemStats": { "HeapAlloc": 108681552, "HeapInUse": 144924672, "TotalAlloc": 294147416 }, "WorkspaceStats": { "Files": { "Total": 6971, "Largest": 7361676, "Errs": 0 }, "Views": [ { "GoCommandVersion": "go1.22.0", "AllPackages": { "Packages": 1426, "LargestPackage": 214, "CompiledGoFiles": 8363, "Modules": 177 }, "WorkspacePackages": { "Packages": 593, "LargestPackage": 214, "CompiledGoFiles": 4074, "Modules": 1 }, "Diagnostics": 0 } ] } }The text was updated successfully, but these errors were encountered: