]> Cypherpunks repositories - gostls13.git/commit
sync: disassociate WaitGroups from bubbles on Wait
authorDamien Neil <dneil@google.com>
Fri, 27 Jun 2025 15:46:28 +0000 (08:46 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 30 Jun 2025 17:44:09 +0000 (10:44 -0700)
commit9ae38be3025fa71ec2967111e0a184f886876cb1
tree9c572a762378961bc2ac10a56333657e1435e4b8
parent4731832342f6430d6eb4cb13a00b97c3db5da993
sync: disassociate WaitGroups from bubbles on Wait

Fix a race condition in disassociating a WaitGroup in a synctest
bubble from its bubble. We previously disassociated the WaitGroup
when count becomes 0, but this causes problems when an Add call
setting count to 0 races with one incrementing the count.

Instead, disassociate a WaitGroup from its bubble when Wait returns.
Wait must not be called concurrently with an Add call with a
positive delta and a 0 count, so we know that the disassociation
will not race with an Add call trying to create a new association.

Fixes #74386

Change-Id: I9b519519921f7691869a64a245a5ee65d071d054
Reviewed-on: https://go-review.googlesource.com/c/go/+/684635
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/internal/synctest/synctest_test.go
src/sync/waitgroup.go