Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
adonovan opened this issue Apr 8, 2025 · 0 comments
Labels
gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@adonovan
Copy link
Member

adonovan commented Apr 8, 2025

#!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

@adonovan adonovan added gopls Issues related to the Go language server, gopls. gopls/telemetry-wins NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/memory-corruption "can't happen" gopls crashes (races, unsafe, miscompile, runtime bugs, faulty HW) gopls/telemetry-wins gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

1 participant