Skip to content

x/tools/gopls: Implementation: OOB index panic in unify #75525

@adonovan

Description

@adonovan
#!stacks
"goPanicIndex" && "fingerprint.unify.func3:+8"

Issue created by stacks.

func unify(x, y sexpr) bool {

	// maxTypeParam returns the maximum type parameter index in x.
	var maxTypeParam func(x sexpr) int
	maxTypeParam = func(x sexpr) int {...}
...
	yBindings := make([]*sexpr, maxTypeParam(y)+1)
	for i := range len(yBindings) {
		yBindings[i] = new(sexpr)
	}

	// bind sets binding b to s from bindings if it does not occur in s.
	bind := func(b *sexpr, s sexpr, bindings []*sexpr) bool {
...
	var uni func(x, y sexpr) bool
	uni = func(x, y sexpr) bool {
		var bx, by *sexpr
		ix := typeParamIndex(x)
		if ix >= 0 {
			bx = xBindings[ix]
		}
		iy := typeParamIndex(y)
		if iy >= 0 {
			by = yBindings[iy] // OOB index panic

This stack FSaUqg was reported by telemetry:

golang.org/x/tools/[email protected] go1.24.6 linux/amd64 vscode (1)

Metadata

Metadata

Assignees

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