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: "unexpected file: %q" bug.Report in bestView (reported by telemetry) #67288

Open
adonovan opened this issue May 10, 2024 · 4 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

adonovan commented May 10, 2024

#!stacks
"bug.Errorf:+2" && "cache.port.matches.func1:+2"

This stack FC7EOg was reported by telemetry:

// matches reports whether the port matches a file with the given absolute path
// and content.
...
func (p port) matches(path string, content []byte) bool {
...
	// The only virtualized operation called by MatchFile is OpenFile.
	ctxt.OpenFile = func(p string) (io.ReadCloser, error) {
		if p != path {
			return nil, bug.Errorf("unexpected file %q", p)
		}
		return io.NopCloser(bytes.NewReader(content)), nil
	}
...

gopls/bug

golang.org/x/tools/gopls@v0.16.1 go1.23.0 linux/amd64 other (1)
golang.org/x/tools/gopls@v0.15.3 go1.22.2 darwin/arm64 neovim (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

Dups: LJo3VQ qOsYYQ oVfJVw

@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 May 10, 2024
@gopherbot gopherbot added this to the Unreleased milestone May 10, 2024
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.16.0 May 10, 2024
@adonovan
Copy link
Member Author

This stack LJo3VQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Errorf:+2
golang.org/x/tools/gopls/internal/cache.port.matches.func1:+2
go/build.(*Context).openFile:+2
go/build.(*Context).matchFile:+27
go/build.(*Context).MatchFile:=1398
golang.org/x/tools/gopls/internal/cache.port.matches:+15
golang.org/x/tools/gopls/internal/cache.bestView[...]:+23
golang.org/x/tools/gopls/internal/cache.(*Session).viewOfLocked:+8
golang.org/x/tools/gopls/internal/cache.(*Session).DidModifyFiles:+133
golang.org/x/tools/gopls/internal/server.(*server).didModifyFiles:+36
golang.org/x/tools/gopls/internal/server.(*server).DidOpen:+20
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+253
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls@v0.15.3 go1.22.2 linux/amd64 neovim (2)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

@findleyr findleyr self-assigned this May 31, 2024
@findleyr
Copy link
Contributor

The build.MatchFile API is quite hard to use.

I don't know what this could be, but also don't think it's likely to be that impactful. Let's punt to the next milestone.

@adonovan
Copy link
Member Author

adonovan commented Sep 9, 2024

This stack qOsYYQ was reported by telemetry:

gopls/bug
golang.org/x/tools/gopls/internal/util/bug.report:+35
golang.org/x/tools/gopls/internal/util/bug.Errorf:+2
golang.org/x/tools/gopls/internal/cache.port.matches.func1:+2
go/build.(*Context).openFile:+2
go/build.(*Context).matchFile:+27
go/build.(*Context).MatchFile:=1420
golang.org/x/tools/gopls/internal/cache.port.matches:+15
golang.org/x/tools/gopls/internal/cache.matchingView[...]:+23
golang.org/x/tools/gopls/internal/cache.selectViewDefs:+59
golang.org/x/tools/gopls/internal/cache.(*Session).DidModifyFiles:+93
golang.org/x/tools/gopls/internal/server.(*server).didModifyFiles:+36
golang.org/x/tools/gopls/internal/server.(*server).DidOpen:+20
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+253
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.handshaker.func4:+52
golang.org/x/tools/gopls/internal/protocol.Handlers.MustReplyHandler.func1:+2
golang.org/x/tools/gopls@v0.16.1 go1.23.0 linux/amd64 neovim (1)

Issue created by golang.org/x/tools/gopls/internal/telemetry/cmd/stacks.

gopherbot pushed a commit to golang/tools that referenced this issue Sep 12, 2024
This CL causes the stacks command to mark up each stack as a
set of links to CodeSearch. In order to do that, it needs to
build the gopls executable at the correct version of gopls and Go
and for the right GOOS and GOARCH, read the pclntab out of the
executable (which is the only authority on how to decode the
symbol names that appear in the stack counter), and then
construct CodeSearch URLs from (version, file, line) triples.

The expensive steps are cached in /tmp/gopls-stacks so that they
are paid infrequently in a typical stacks run.

See golang/go#67288 for an example
of the updated output.

Fixes golang/go#64654

Change-Id: If1c3e42af5550114515b47a22dfa036e8da27143
Reviewed-on: https://go-review.googlesource.com/c/tools/+/611840
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
@findleyr findleyr modified the milestones: gopls/v0.17.0, gopls/v0.18.0 Nov 6, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/626015 mentions this issue: gopls/internal/cache: guard against malformed paths in port.matches

gopherbot pushed a commit to golang/tools that referenced this issue Nov 7, 2024
It's possible that we may encounter the path inconsistency of
golang/go#67288 due to unclean or relative paths. Guard against this
with a new bug report.

For golang/go#67288

Change-Id: I37ac1f74334bcb9e955d75e436f74398c73f0acb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/626015
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
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