-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
AutomationIssues created by gopherbot or watchflakes automation.Issues created by gopherbot or watchflakes automation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins
Milestone
Description
#!stacks
"gopls/bug" && "collectFreeVars:+3" && "extractFunctionMethod"
Issue created by stacks.
This is a strange one: info.Scopes has no entry for a file, despite the file being non-nil with a valid FileStart (i.e. something produced by the parser), ultimately having come from NarrowestPackageForFile (in ApplyFix), i.e. having been type checked. This points to memory corruption again.
file := pgf.Cursor.Node().(*ast.File)
tok := fset.File(file.FileStart) <--- must be non-nil
if tok == nil {
return nil, nil, bug.Errorf("no file for position") <-- file has valid FileStart
}
...
variables, err := collectFreeVars(info, file, start, end, path[0])
func collectFreeVars(info *types.Info, file *ast.File, start, end token.Pos, node ast.Node) ([]*variable, error) {
fileScope := info.Scopes[file]
if fileScope == nil {
return nil, bug.Errorf("file scope is empty") <--------- reached
}This stack HG8yiA was reported by telemetry:
gopls/buggolang.org/x/tools/gopls/internal/util/bug.report:+35,+0x412golang.org/x/tools/gopls/internal/util/bug.Errorf:+2,+0x34golang.org/x/tools/gopls/internal/golang.collectFreeVars:+3,+0x3d2golang.org/x/tools/gopls/internal/golang.extractFunctionMethod:+103,+0x42egolang.org/x/tools/gopls/internal/golang.extractFunction:+2,+0x4dgolang.org/x/tools/gopls/internal/golang.ApplyFix.singleFile.func2:+1,+0x23golang.org/x/tools/gopls/internal/golang.ApplyFix:+43,+0x702golang.org/x/tools/gopls/internal/server.(*commandHandler).ApplyFix.func1:+1,+0x85golang.org/x/tools/gopls/internal/server.(*commandHandler).run.func2:+3,+0x86golang.org/x/tools/gopls/internal/server.(*commandHandler).run:+81,+0x582golang.org/x/tools/gopls/internal/server.(*commandHandler).ApplyFix:+2,+0x19cgolang.org/x/tools/gopls/internal/protocol/command.Dispatch:+31,+0xac1golang.org/x/tools/gopls/internal/server.(*server).ResolveCodeAction:+21,+0x1b8golang.org/x/tools/gopls/internal/protocol.serverDispatch:+46,+0xcf9golang.org/x/tools/gopls/internal/lsprpc.(*StreamServer).ServeStream.ServerHandler.func4:+5,+0x84golang.org/x/tools/gopls/internal/lsprpc.(*StreamServer).ServeStream.handshaker.func5:+52,+0x908
golang.org/x/tools/[email protected] go1.24.7 linux/amd64 vscode (1)
Metadata
Metadata
Assignees
Labels
AutomationIssues created by gopherbot or watchflakes automation.Issues created by gopherbot or watchflakes automation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins