#!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/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.defineView:+28 - golang.org/x/tools/gopls/internal/cache.selectViewDefs:+63 - 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 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 9VQqVg hnsAPw

Comment From: adonovan

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.

Comment From: findleyr

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.

Comment From: adonovan

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.

Comment From: gopherbot

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

Comment From: adonovan

This stack 9VQqVg was reported by telemetry:

golang.org/x/tools/gopls@v0.15.2 go1.22.1 linux/amd64 neovim (1)

Comment From: findleyr

Has not recurred in v0.17.x. I don't think this is actionable until it we get a more recent instance.

Comment From: adonovan

This stack hnsAPw was reported by telemetry:

golang.org/x/tools/gopls@v0.16.2 go1.22.5 darwin/arm64 neovim (1)