Skip to content
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

x/tools/gopls: type assertion panics in persistent.Map.Get #72027

Open
adonovan opened this issue Feb 28, 2025 · 2 comments
Open

x/tools/gopls: type assertion panics in persistent.Map.Get #72027

adonovan opened this issue Feb 28, 2025 · 2 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. 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

#!stacks
"panicdottypeE" && "persistent.(*Map[...]).Get:=182"

Issue created by stacks.

// Get returns the map value associated with the specified key.
// The ok result indicates whether an entry was found in the map.
func (pm *Map[K, V]) Get(key K) (V, bool) {
	node := pm.root
	for node != nil {
		if key < node.key.(K) {           <--------- panic
			node = node.left
		} else if node.key.(K) < key {
			node = node.right
		} else {
			return node.value.value.(V), true
		}
	}
	var zero V
	return zero, false
}

This stack BPhXeQ was reported by telemetry:

golang.org/x/tools/[email protected] go1.23.4 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. labels Feb 28, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 28, 2025
@adonovan
Copy link
Member Author

Every variable of type mapNode is constructed with a value for its key field, copied from either another mapNode (the inductive case) or from the k parameter of newNodeWithRef. Therefore this bug, in which its value is not of type k, "can't happen". Another sign of a data race?

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Feb 28, 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/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