Skip to content

x/tools/gopls: SEGV accessing map[string]... #73387

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 15, 2025 · 1 comment
Open

x/tools/gopls: SEGV accessing map[string]... #73387

adonovan opened this issue Apr 15, 2025 · 1 comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Apr 15, 2025

#!stacks
"runtime.sigpanic" &&
   "runtime.mapaccess2_faststr:+84" &&
   "imports.(*DirInfoCache).Load:+3"

Issue created by stacks.

imports.(*DirInfoCache).Load:

	info, ok := d.dirs[dir]

In mapaccess2_faststr below, it looks like one of k, key, or b is an invalid (nil or corrupt) pointer. We know that b and key are non-nil; and k is derived from b.keys(), which is an offset of b; so the only possibility is data corruption.

	top := tophash(hash)
	for ; b != nil; b = b.overflow(t) {
		for i, kptr := uintptr(0), b.keys(); i < abi.MapBucketCount; i, kptr = i+1, add(kptr, 2*goarch.PtrSize) {
			k := (*stringStruct)(kptr)
			if k.len != key.len || b.tophash[i] != top {  <------- SEGV
				continue
			}
			if k.str == key.str || memequal(k.str, key.str, uintptr(key.len)) {
				return add(unsafe.Pointer(b), dataOffset+abi.MapBucketCount*2*goarch.PtrSize+i*uintptr(t.ValueSize)), true
			}
		}
	}

This stack sAEkLA was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.8 linux/amd64 vscode (1)
@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 15, 2025
@gopherbot gopherbot added this to the Unreleased milestone Apr 15, 2025
@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. 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

3 participants