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: Hover: nil deref in golang.StdSymbolOf #70969

Open
adonovan opened this issue Dec 23, 2024 · 3 comments
Open

x/tools/gopls: Hover: nil deref in golang.StdSymbolOf #70969

adonovan opened this issue Dec 23, 2024 · 3 comments
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

#!stacks
"runtime.sigpanic" && "hover:+472"

Issue created by stacks.

	// Handle Method.
	if fn, _ := obj.(*types.Func); fn != nil {
		isPtr, named := typesinternal.ReceiverNamed(fn.Signature().Recv())         //   --panic--
		if isPackageLevel(named.Obj()) {
			for _, s := range symbols {

This stack J7Opuw was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.4 darwin/arm64 vscode (1)
golang.org/x/tools/[email protected] go1.23.4 linux/amd64 vscode (1)
@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Dec 23, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 23, 2024
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.17.2 Dec 23, 2024
@adonovan
Copy link
Member Author

I assume there's the usual off-by-one in the line numbering and that the actual panic is the named.Obj dereference.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/638597 mentions this issue: gopls/internal/golang: check for nil ReceiverNamed

gopherbot pushed a commit to golang/tools that referenced this issue Dec 23, 2024
This is a defensive check against a nil result from ReceiverNamed;

I'm unable to reproduce the panic though. It would have to be
hovering over a reference to a method whose receiver is
not a named type (or alias or pointer to named), such as
a slice type, an undeclared type, or somesuch.

Updates golang/go#70969

Change-Id: I1cc2bc3d311a88304a2af525d38c1143f4c513a1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/638597
Auto-Submit: Alan Donovan <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants