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: "negative WaitGroup counter" panic in diagnoseChangedViews #71177

Open
adonovan opened this issue Jan 8, 2025 · 6 comments
Open
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime. 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.

Comments

@adonovan
Copy link
Member

adonovan commented Jan 8, 2025

#!stacks
"runtime.gopanic" && "sync.(*WaitGroup).Add:+19" && "diagnoseChangedViews.func1:+16`"

Issue created by stacks.

func (wg *WaitGroup) Add(delta int) {
...
	state := wg.state.Add(uint64(delta) << 32)
	v := int32(state >> 32)
	w := uint32(state)
...
	if v < 0 {
		panic("sync: negative WaitGroup counter") // <---------- here
	}

This stack OKWeGA was reported by telemetry:

golang.org/x/tools/gopls@v0.17.1 go1.23.3 linux/amd64 vscode (1)
@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. gopls/telemetry-wins labels Jan 8, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 8, 2025
@adonovan
Copy link
Member Author

adonovan commented Jan 8, 2025

I can't explain this. Calls to Add and Done are strictly paired and the Done always happens after the Add. There are no other salient uses of the WaitGroup.

Paging compiler and runtime folks. @prattmic

@prattmic
Copy link
Member

prattmic commented Jan 9, 2025

I agree, this use of WaitGroup looks straightforward and bug free to me.

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Jan 10, 2025
@adonovan
Copy link
Member Author

I think the symptom must indicate one of these causes:

  • the WaitGroup counter overflowed, which is impossible because the length of the range slice is never more than a small handful;
  • wg.Done was called before the completion of its corresponding Add, which is impossible in a correct translation of the program;
  • the heap-allocated local variable wg was clobbered by software: this indicates either general memory corruption, or a bug in the runtime (e.g. GC);
  • a hardware fault, e.g. bad RAM, or a cosmic ray shower flipped the sign bit of the semaphore.

@findleyr findleyr modified the milestones: Unreleased, gopls/backlog Jan 10, 2025
@findleyr
Copy link
Member

I don't know what to do with this, so moving it to the backlog rather than next release milestone.

@adonovan
Copy link
Member Author

I think we should send it to the runtime folks, since there's nothing we can do in gopls.

@adonovan adonovan added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 10, 2025
@adonovan adonovan removed this from the gopls/backlog milestone Jan 10, 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. compiler/runtime Issues related to the Go compiler and/or runtime. 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
Status: No status
Development

No branches or pull requests

5 participants