Skip to content

x/tools/gopls: SEGV in gcimporter.iexportCommon (bad SP) #72135

@adonovan

Description

@adonovan
#!stacks
"sigpanic" && "gcimporter.(*iexporter).pushDecl:+0"

Issue created by stacks.

	for _, pkg := range pkgs {
		scope := pkg.Scope()
		for _, name := range scope.Names() {
			if token.IsExported(name) {
				p.pushDecl(scope.Lookup(name))  <---- in this call
func (p *iexporter) pushDecl(obj types.Object) { <---- SEGV
	// Package unsafe is known to the compiler and predeclared.
	// Caller should not ask us to do export it.
	if obj.Pkg() == types.Unsafe {

All memory-operand instructions on that source line are indicated by the comments below. None can fail unless the SP register or g (R14) is bad.

TEXT golang.org/x/tools/internal/gcimporter.(*iexporter).pushDecl(SB) /Users/adonovan/w/xtools/internal/gcimporter
/iexport.go
  iexport.go:654        0x16cd9c0               493b6610                CMPQ SP, 0x10(R14)	// load g.stackguard_00
  iexport.go:654        0x16cd9c4               0f86d4000000            JBE 0x16cda9e
  iexport.go:654        0x16cd9ca               55                      PUSHQ BP		// save FP
  iexport.go:654        0x16cd9cb               4889e5                  MOVQ SP, BP
  iexport.go:654        0x16cd9ce               4883ec18                SUBQ $0x18, SP
  ...
  iexport.go:654        0x16cd9d7               48895c2430              MOVQ BX, 0x30(SP)	// spill obj.t
  iexport.go:654        0x16cd9dc               48894c2438              MOVQ CX, 0x38(SP)	// spill obj.v

This stack R1nKxA was reported by telemetry:

golang.org/x/tools/gopls@v0.17.1 go1.23.4 darwin/amd64 neovim,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.compiler/runtimeIssues related to the Go compiler and/or runtime.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

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions