From: Nicolas Hillegeer Date: Tue, 21 Oct 2025 11:43:36 +0000 (-0700) Subject: sync: re-enable race even when panicking X-Git-Tag: go1.26rc1~546 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8f74f9daf4d2fe708cf28d0e2b9cce079fa19248;p=gostls13.git sync: re-enable race even when panicking Not doing this can cause user code running after this panic (e.g.: defers) to produce non-existing races. Change-Id: Ia6aec88aaeee3b9c17e7b8019d697ffa88dfb492 Reviewed-on: https://go-review.googlesource.com/c/go/+/713460 Commit-Queue: Nicolas Hillegeer Reviewed-by: Michael Pratt Auto-Submit: Nicolas Hillegeer Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI --- diff --git a/src/sync/waitgroup.go b/src/sync/waitgroup.go index 5b035aa396..195f839da4 100644 --- a/src/sync/waitgroup.go +++ b/src/sync/waitgroup.go @@ -204,13 +204,14 @@ func (wg *WaitGroup) Wait() { } } runtime_SemacquireWaitGroup(&wg.sema, synctestDurable) - if wg.state.Load() != 0 { - panic("sync: WaitGroup is reused before previous Wait has returned") - } + isReset := wg.state.Load() != 0 if race.Enabled { race.Enable() race.Acquire(unsafe.Pointer(wg)) } + if isReset { + panic("sync: WaitGroup is reused before previous Wait has returned") + } return } }