Description
#!stacks
"runtime.goPanicSliceAcap" && "frob.(*reader).bytes"
Issue created by stacks.
func (r *reader) bytes(n int) []byte {
v := r.data[:n]
r.data = r.data[n:] // <--- panic
return v
}
This stack MZjt-Q
was reported by telemetry:
crash/crash
runtime.gopanic:+69
golang.org/x/tools/gopls/internal/cache.assert:=10
golang.org/x/tools/gopls/internal/cache.(*packageHandleBuilder).evaluatePackageHandle.func1:+2
runtime.gopanic:+50
runtime.goPanicSliceAcap:+2
golang.org/x/tools/gopls/internal/util/frob.(*reader).bytes:=392
golang.org/x/tools/gopls/internal/util/frob.(*frob).Decode:+6
golang.org/x/tools/gopls/internal/util/frob.Codec[...].Decode:=53
golang.org/x/tools/gopls/internal/cache/typerefs.decode:+2
golang.org/x/tools/gopls/internal/cache/typerefs.Decode:=42
golang.org/x/tools/gopls/internal/cache.(*Snapshot).typerefs:+12
golang.org/x/tools/gopls/internal/cache.(*packageHandleBuilder).evaluatePackageHandle:+53
golang.org/x/tools/gopls/internal/cache.(*Snapshot).getPackageHandles.func2.1:+8
golang.org/x/sync/errgroup.(*Group).Go.func1:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.17.1 go1.23.3 linux/amd64 vscode (1)
Metadata
Metadata
Assignees
Labels
Issues describing a possible bug in the Go implementation.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.This label describes issues relating to any tools in the x/tools repository.Issues related to the Go language server, gopls."can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
adonovan commentedon Jan 13, 2025
If the line number is accurate, the
r.data[n:]
operation is implicated, but it cannot fail if ther.data[:n]
operation on the previous line succeeded. So this makes me doubt the line number.Looking at the disassembly, the check whose failure calls panicSliceACap is the very first thing the function does after its prolog:
This implicates the first slice operation---and means the line number is indeed off by one.
In any case, the frob decoder is clearly being fed an illegal short message that doesn't even contain the 4-byte magic number.
adonovan commentedon Jan 13, 2025
This looks like a consequence of execution continuing after the failed bug.Reportf in typerefData:
The bug.Reportf should be turned into
return bug.Errorf
.[Edit: nope, the code here looks fine. An unexpected error is just a cache miss. The problem must come either from Get returning a tiny or empty file and no error.]
gopherbot commentedon Jan 13, 2025
Change https://go.dev/cl/642435 mentions this issue:
gopls/internal/cache: Snapshot.typerefData: add missing error return
gabyhelp commentedon Jan 13, 2025
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
adonovan commentedon Jan 13, 2025
This is a really weird one. What we know:
The only explanations I can think of are:
What am I missing?
gopls/internal/util/frob: Decode: improve panic on empty
findleyr commentedon Jan 13, 2025
Skimming
filecache.gc
, it doesn't look like we care to delete the casfile before the content file. Therefore, doesn't it seem possible that we could read the content file concurrent to a deletion?EDIT: err, I suppose the order of deletion doesn't really matter: the fact is we could try to read a content file concurrent with another process GCing that file.
EDIT2: nevermind, we'd fail the hash comparison, of course. OK, I agree that I don't understand this.
findleyr commentedon Jan 15, 2025
I don't think we can fix this for v0.18.0, nor do I think we should avoid it.
Moving this to the backlog. We can revisit if there are additional occurrences.
adonovan commentedon Jan 22, 2025
I've refined the failure (to an explicit panic). Not sure what more to do for now.