Skip to content

x/tools/gopls: SEGV in go/types due to invalid pointer in BinaryExpr.Y #76238

@adonovan

Description

@adonovan
#!stacks
"sigpanic" && "go/types.(*Checker).exprInternal:+156" && "go/types.(*Checker).binary:+4"

Issue created by stacks.

The type checker panics in its default case. This means one of:

  • the type switch is non-exhaustive. But that's not the case, as the only ast.Expr types in gopls (according to gopls) are those defined in the go/ast package, for which the type switch is complete;
  • e is nil. This is unexpected, but go/types ought not to panic while constructing the panic message. The value of e comes from BinaryExpr.Y. For BinaryExprs originating in the parser, the Y field is always non-nil even on case of parse error. The only other BinaryExpr values constructed within gopls are from the inliner's falcon analysis. Looking over all 4 composite literals, three are dominated by a check of Y != nil. One is not. That seems like a bug. [Actually, all four.] However, the falcon constraint expressions are type-checked by CheckExpr, so the presence of funcDecl on the call stack rejects that theory, leaving:
  • e is an invalid non-nil pointer and we're looking at memory corruption or bad hardware.

This stack ElUPug was reported by telemetry:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions