#!stacks
"sigpanic" && "cache.(*Snapshot).GoCommandInvocation:+5"
Issue created by stacks.
func (s *Snapshot) GoCommandInvocation(allowNetwork AllowNetwork, dir, verb string, args []string, env ...string) (_ *gocommand.Invocation, cleanup func(), _ error) {
inv := &gocommand.Invocation{
Verb: verb,
Args: args,
WorkingDir: dir,
Env: append(s.view.Env(), env...), // <--- nil deref
called from here:
func (c *commandHandler) Vendor(ctx context.Context, args command.URIArg) error {
return c.run(ctx, commandConfig{ ...
}, func(ctx context.Context, deps commandDeps) error
...
inv, cleanupInvocation, err := deps.snapshot.GoCommandInvocation(cache.NetworkOK, args.URI.DirPath(), "mod", []string{"vendor"})
The crash implies that either deps.snapshot or deps.snapshot.view is nil. The first cannot be the case because of the early return in c.run. The second cannot be the case because it's an immutable field of Snapshot that is non-nil at construction. So I think this is yet another case of memory corruption.
This stack wY83jw
was reported by telemetry:
crash/crash
runtime.gopanic:+69
runtime.panicmem:=262
runtime.sigpanic:+19
golang.org/x/tools/gopls/internal/cache.(*Snapshot).GoCommandInvocation:+5
golang.org/x/tools/gopls/internal/server.(*commandHandler).Vendor.func1:+10
golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3
golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+81
golang.org/x/tools/gopls/internal/server.(*commandHandler).Vendor:+1
golang.org/x/tools/gopls/internal/protocol/command.Dispatch:+226
golang.org/x/tools/gopls/internal/server.(*server).ExecuteCommand:+28
golang.org/x/tools/gopls/internal/protocol.serverDispatch:+674
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/internal/protocol.Handlers.AsyncHandler.func2.2:+3
runtime.goexit:+0
golang.org/x/tools/gopls@v0.18.1 go1.24.0 darwin/arm64 neovim,vscode (5)
Comment From: gabyhelp
Related Issues
- x/tools/gopls: nil deref in Snapshot.MetadataForFile #73114
- x/tools/gopls: nil deref panic in go.test code action #72907 (closed)
- x/tools/gopls: Package.Path called on nil Package in AddTestForFunc #73687 (closed)
- x/tools/gopls: call to IsGenerated ocassionally has nil Snapshot causing panic #41778 (closed)
- x/tools/gopls: nil deref in x/telemetry/internal/counter.(*Counter).add #73890
- x/tools/gopls: automated issue report (crash) #40449 (closed)
- x/tools/gopls: Hover: nil deref in parseDocLink #70635 (closed)
- x/tools/gopls: nil deref in Exporter.ProcessEvent #71928
- x/tools/gopls: panic because of nil pointer in cache.fileWasSaved #37687 (closed)
- x/tools/gopls: Completion: nil deref in expectedCompositeLiteralType #72136 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)