Skip to content

go/types: SEGV while loading types.Var.name field (lookupScope returns invalid *types.Var) #73261

@adonovan

Description

@adonovan
#!stacks
"sigpanic" && "types.(*Var).Name:+0" && "go/types.(*Checker).ident:+30"

Issue created by stacks.

We have a non-nil Object interface value (witness dominating control flow), evidently containing a *types.Var (see traceback), whose Name() method call crashes. The only instruction in Var.Name is a 2-word load from the object.name field, so the *types.Var pointer is either nil or invalid.

	scope, obj := check.lookupScope(e.Name)
	switch obj {
	case nil:
		...
		return
	...
	}
	...
	_, gotType := obj.(*TypeName)
	if !gotType && wantType {
	  	check.errorf(e, NotAType, "%s is not a type", obj.Name())  <----- panic loading offset 24 of *types.Var pointer

This stack t8TEng was reported by telemetry:

golang.org/x/tools/gopls@v0.18.1 go1.23.6 linux/amd64 vscode (1)

@griesemer

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone 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.goplsIssues related to the Go language server, gopls.gopls/memory-corruption"can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW)gopls/telemetry-wins

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions