Skip to content
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 with modules named "command-line-arguments" #61543

Closed
Martin-Jia opened this issue Jul 19, 2023 · 9 comments
Closed

x/tools/gopls: crash with modules named "command-line-arguments" #61543

Martin-Jia opened this issue Jul 19, 2023 · 9 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@Martin-Jia
Copy link

gopls version: v0.12.4 (go1.20.6)
gopls flags:
update flags: proxy
extension version: 0.39.1
go version: 1.20.6
environment: Visual Studio Code linux
initialization error: undefined
issue timestamp: Wed, 19 Jul 2023 16:26:40 GMT
restart history:
Wed, 19 Jul 2023 16:26:31 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

Failed to open any go file. It showed up that the gopls server crashed. Reopen window did not help.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0xbfb1f8]

goroutine 3867 [running]:
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc000e66080, 0x1a})
	  check.go:787  0x178
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc001034e40, 0x52})
	  check.go:788  0x1d7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles(0xc00440c000, {0x115b1f8, 0xc004359170}, {0xc0043579c0, 0x1, 0x0%3F})
	  check.go:792  0x246
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackage(0x115b1f8%3F, {0x115b1f8, 0xc004358ff0}, {0xc0043579c0, 0x1, 0x1}, 0xc0043579c0%3F, 0x0%3F)
	  check.go:341  0x1d9
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).PackageDiagnostics(0xc003e04f68%3F, {0x115b1f8%3F, 0xc003aff380%3F}, {0xc0043579c0, 0x1, 0x1})
	  snapshot.go:666  0x1fc
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs.func1()
	  diagnostics.go:441  0x1dc
created by golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs
	  diagnostics.go:434  0x205
[Error - 4:26:38 PM] 

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.

<OPTIONAL: ATTACH LOGS HERE>

@Martin-Jia
Copy link
Author

[Info - 4:26:38 PM] 2023/07/19 16:26:38 go/packages.Load golang/vscode-go#1: updating metadata for 593 packages

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0xbfb1f8]

goroutine 3867 [running]:
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc000e66080, 0x1a})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:787 +0x178
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc001034e40, 0x52})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:788 +0x1d7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles(0xc00440c000, {0x115b1f8, 0xc004359170}, {0xc0043579c0, 0x1, 0x0?})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:792 +0x246
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackage(0x115b1f8?, {0x115b1f8, 0xc004358ff0}, {0xc0043579c0, 0x1, 0x1}, 0xc0043579c0?, 0x0?)
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:341 +0x1d9
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).PackageDiagnostics(0xc003e04f68?, {0x115b1f8?, 0xc003aff380?}, {0xc0043579c0, 0x1, 0x1})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/snapshot.go:666 +0x1fc
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs.func1()
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/diagnostics.go:441 +0x1dc
created by golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/diagnostics.go:434 +0x205
[Error - 4:26:38 PM] Connection to server got closed. Server will not be restarted.

@findleyr
Copy link
Contributor

Hi @Martin-Jia are you able to reproduce this reliable? Is this on an open-source repository?

@Martin-Jia
Copy link
Author

Yes I can reproduce this reliable. This is not an open source repo.

@findleyr
Copy link
Contributor

@Martin-Jia could you please try installing gopls@master? The panic has been enhanced with more information. It would be incredibly helpful if you could assist us in investigating.

git clone go.googlesource.com/tools
cd tools/gopls
go install

CC @adonovan

@jamalc jamalc added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 20, 2023
@Martin-Jia
Copy link
Author

Thanks @findleyr
I'm not sure if I did wrong. I couldn't clone the repo from googlesource.com, so I tried go install golang.org/x/tools/gopls@master instead, and restarted vscode.
But I saw nothing different.

[Info - 10:58:22 AM] 2023/07/21 10:58:22 go/packages.Load golang/vscode-go#6: updating metadata for 548 packages

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb8 pc=0xbfb1f8]

goroutine 21960 [running]:
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc0009503c0, 0x1e})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:787 +0x178
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles.func1({0xc0074c3b60, 0x52})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:788 +0x1d7
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).getPackageHandles(0xc00d240900, {0x115b1f8, 0xc00e8de420}, {0xc00e8c1b60, 0x1, 0x0?})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:792 +0x246
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).forEachPackage(0x115b1f8?, {0x115b1f8, 0xc00e8de2a0}, {0xc00e8c1b60, 0x1, 0x1}, 0xc00e8c1b60?, 0x0?)
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/check.go:341 +0x1d9
golang.org/x/tools/gopls/internal/lsp/cache.(*snapshot).PackageDiagnostics(0xc00e295f68?, {0x115b1f8?, 0xc00e220150?}, {0xc00e8c1b60, 0x1, 0x1})
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/cache/snapshot.go:666 +0x1fc
golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs.func1()
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/diagnostics.go:441 +0x1dc
created by golang.org/x/tools/gopls/internal/lsp.(*Server).diagnosePkgs
/home/mingj/go/pkg/mod/golang.org/x/tools/gopls@v0.12.4/internal/lsp/diagnostics.go:434 +0x205
[Error - 10:58:22 AM] Connection to server got closed. Server will not be restarted.

@Martin-Jia
Copy link
Author

We later found that the issue may potentially relate with the project module name. The module name used to be "command-line-arguments". After we changed it to another one, for example, github.com/x/y/z, the issue just disappeared.
Another phenomenon I have observed was that if the module named as github.com/command-line-arguments, it still had the error, though those who use goland just worked fine.

@findleyr
Copy link
Contributor

Aha! Thanks for the clue. Yes, I think that may do it. I'll try to reproduce and fix.

@findleyr findleyr changed the title gopls: automated issue report (crash) x/tools/gopls: crash with modules named "command-line-arguments" Jul 24, 2023
@findleyr findleyr self-assigned this Jul 24, 2023
@findleyr findleyr transferred this issue from golang/vscode-go Jul 24, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 24, 2023
@findleyr findleyr added this to the gopls/v0.12.5 milestone Jul 24, 2023
@gopherbot gopherbot modified the milestones: gopls/v0.12.5, Unreleased Jul 24, 2023
@findleyr findleyr removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 24, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.13.0 Jul 24, 2023
@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.15.0 Oct 9, 2023
@findleyr findleyr modified the milestones: gopls/v0.15.0, gopls/v0.16.0 Dec 12, 2023
@gopherbot
Copy link

Change https://go.dev/cl/578455 mentions this issue: gopls/internal/cache: fail loudly on command-line-arguments modules

@adonovan
Copy link
Member

adonovan commented Apr 12, 2024

We later found that the issue may potentially relate with the project module name. The module name used to be "command-line-arguments". After we changed it to another one, for example, github.com/x/y/z, the issue just disappeared.

I'm curious what motivated this choice of module name. Does the package actually concern command-line argument processing? Was the name chosen in a confused attempt to match the name of an ad-hoc package printed by go list? Or was this a case of naming your child "little bobby tables"? ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants