#!stacks
"sigpanic" && "modindex.(*Index).Lookup" && "cache.(*goplsSource).resolveCacheReferences"
Issue created by stacks.
func (s *goplsSource) resolveCacheReferences(missing imports.References) ([]*result, error) {
ix, err := s.S.view.ModcacheIndex()
if err != nil {
event.Error(s.ctx, "resolveCacheReferences", err) <----------- missing return
}
found := make(map[string]*result)
for pkg, nms := range missing {
var ks []string
for k := range nms {
ks = append(ks, k)
}
cs := ix.LookupAll(pkg, ks...) // map[importPath][]Candidate <-------- panics within here
This stack sKaGhw
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x153
runtime.panicmem:=262,+0x2ff
runtime.sigpanic:+19,+0x2cc
golang.org/x/tools/internal/modindex.(*Index).Lookup:+1,+0x38
golang.org/x/tools/internal/modindex.(*Index).LookupAll:+5,+0x9f
golang.org/x/tools/gopls/internal/cache.(*goplsSource).resolveCacheReferences:+12,+0x16b
golang.org/x/tools/gopls/internal/cache.(*goplsSource).ResolveReferences:+16,+0x143
golang.org/x/tools/internal/imports.addExternalCandidates:+4,+0x97
golang.org/x/tools/internal/imports.getFixesWithSource:+73,+0x2df
golang.org/x/tools/internal/imports.FixImports:+12,+0x13f
golang.org/x/tools/gopls/internal/golang.computeImportEdits:+24,+0x20f
golang.org/x/tools/gopls/internal/golang.allImportsFixes.func1:+1,+0x4b
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc:+42,+0x2e3
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc:=414,+0xbf
golang.org/x/tools/gopls/internal/golang.allImportsFixes:+4,+0x70
golang.org/x/tools/gopls/internal/golang.(*allImportsFixesResult).init:+1,+0x43
golang.org/x/tools/gopls/internal/golang.lazyInit[...]:+8,+0xa3
golang.org/x/tools/gopls/internal/golang.sourceOrganizeImports:+1,+0x43
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 darwin/arm64 other,vscode (1)
Dups: nSR9Wg x4Uhuw
Comment From: adonovan
The fix may be as simple as a return statement. Whatever it is, let's cherrypick it into rc3.
Comment From: adonovan
This stack nSR9Wg
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x167
runtime.panicmem:=262,+0x358
runtime.sigpanic:+19,+0x328
golang.org/x/tools/internal/modindex.(*Index).Lookup:+1,+0x4d
golang.org/x/tools/internal/modindex.(*Index).LookupAll:+5,+0xc8
golang.org/x/tools/gopls/internal/cache.(*goplsSource).resolveCacheReferences:+12,+0x1d4
golang.org/x/tools/gopls/internal/cache.(*goplsSource).ResolveReferences:+16,+0x14c
golang.org/x/tools/internal/imports.addExternalCandidates:+4,+0xbc
golang.org/x/tools/internal/imports.getFixesWithSource:+73,+0x476
golang.org/x/tools/internal/imports.FixImports:+12,+0x1cd
golang.org/x/tools/gopls/internal/golang.computeImportEdits:+24,+0x251
golang.org/x/tools/gopls/internal/golang.allImportsFixes.func1:+1,+0x49
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc:+42,+0x333
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc:=414,+0x106
golang.org/x/tools/gopls/internal/golang.allImportsFixes:+4,+0x93
golang.org/x/tools/gopls/internal/golang.(*allImportsFixesResult).init:+1,+0x4f
golang.org/x/tools/gopls/internal/golang.lazyInit[...]:+8,+0xa5
golang.org/x/tools/gopls/internal/golang.sourceOrganizeImports:+1,+0x46
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 linux/amd64 other,vscode (1)
This stack x4Uhuw
was reported by telemetry:
crash/crash
runtime.gopanic:+69,+0x167
runtime.panicmem:=262,+0x358
runtime.sigpanic:+19,+0x328
golang.org/x/tools/internal/modindex.(*Index).Lookup:+1,+0x4d
golang.org/x/tools/internal/modindex.(*Index).LookupAll:+5,+0xc8
golang.org/x/tools/gopls/internal/cache.(*goplsSource).resolveCacheReferences:+12,+0x1d4
golang.org/x/tools/gopls/internal/cache.(*goplsSource).ResolveReferences:+16,+0x14c
golang.org/x/tools/internal/imports.addExternalCandidates:+4,+0xbc
golang.org/x/tools/internal/imports.getFixesWithSource:+73,+0x476
golang.org/x/tools/internal/imports.FixImports:+12,+0x1cd
golang.org/x/tools/gopls/internal/golang.computeImportEdits:+24,+0x251
golang.org/x/tools/gopls/internal/golang.allImportsFixes.func1:+1,+0x49
golang.org/x/tools/gopls/internal/cache.(*importsState).runProcessEnvFunc:+42,+0x333
golang.org/x/tools/gopls/internal/cache.(*Snapshot).RunProcessEnvFunc:=414,+0x106
golang.org/x/tools/gopls/internal/golang.allImportsFixes:+4,+0x93
golang.org/x/tools/gopls/internal/golang.(*allImportsFixesResult).init:+1,+0x4f
golang.org/x/tools/gopls/internal/golang.lazyInit[...]:+8,+0xa5
golang.org/x/tools/gopls/internal/golang.quickFix:+7,+0x50
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.2 linux/amd64 vscode (5)
golang.org/x/tools/gopls@v0.19.0-pre.2 go1.24.3 linux/amd64 other,vscode (37)
Comment From: gabyhelp
Related Issues
- x/tools/gopls: nil deref panic in go.test code action #72907 (closed)
- x/tools/gopls: nil deref in 'go vendor' Snapshot.GoCommandInvocation #73891
- x/tools/gopls: nil panic in types.Package.Path while writing export data (internal/gcimporter) #73854
- x/tools/gopls: panic after failed PosRange in xrefs.Index #67704
- x/tools/gopls: "package name is %q, want %q" bug in typeCheckBatch.importPackage #64235
- x/tools/gopls: bug in analysis importer reported by telemetry #64236 (closed)
- x/tools/gopls: xrefs.Index panics after "can't fail" pgf.PosRange #70446 (closed)
- x/tools/gopls: nil deref in Exporter.ProcessEvent #71928
- x/tools/gopls: CodeAction: nil panic in findMatchingDiagnostics #71028 (closed)
- x/tools/gopls: imports.ApplyFixes panics with "invalid line number %d (should be \< %d)" #73587 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/680258 mentions this issue: gopls/internal/cache: add missing error check