From 4f86f2267167a63b673c4a2a2994e008b32c90ea Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Thu, 5 Jun 2025 13:47:06 -0700 Subject: testing/synctest, runtime: avoid panic when using linker-alloc WG from bubble We associate WaitGroups with synctest bubbles by attaching a special to the WaitGroup. It is not possible to attach a special to a linker-allocated value, such as: var wg sync.WaitGroup Avoid panicking when accessing a linker-allocated WaitGroup from a bubble. We have no way to associate these WaitGroups with a bubble, so just treat them as always unbubbled. This is probably fine, since the WaitGroup was always created outside the bubble in this case. Fixes #74005 Change-Id: Ic71514b0b8d0cecd62e45cc929ffcbeb16f54a55 Reviewed-on: https://go-review.googlesource.com/c/go/+/679695 Reviewed-by: Michael Knyszek Auto-Submit: Damien Neil LUCI-TryBot-Result: Go LUCI --- src/testing/synctest/synctest.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/testing') diff --git a/src/testing/synctest/synctest.go b/src/testing/synctest/synctest.go index 57a6fbfbd6..0911519aab 100644 --- a/src/testing/synctest/synctest.go +++ b/src/testing/synctest/synctest.go @@ -93,6 +93,11 @@ // A [sync.WaitGroup] becomes associated with a bubble on the first // call to Add or Go. Once a WaitGroup is associated with a bubble, // calling Add or Go from outside that bubble is a fatal error. +// (As a technical limitation, a WaitGroup defined as a package +// variable, such as "var wg sync.WaitGroup", cannot be associated +// with a bubble and operations on it may not be durably blocking. +// This limitation does not apply to a *WaitGroup stored in a +// package variable, such as "var wg = new(sync.WaitGroup)".) // // [sync.Cond.Wait] is durably blocking. Waking a goroutine in a bubble // blocked on Cond.Wait from outside the bubble is a fatal error. -- cgit v1.3