Skip to content

Commit 8f74f9d

Browse files
aktaugopherbot
authored andcommitted
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 <aktau@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Nicolas Hillegeer <aktau@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 8a6c64f commit 8f74f9d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/sync/waitgroup.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,14 @@ func (wg *WaitGroup) Wait() {
204204
}
205205
}
206206
runtime_SemacquireWaitGroup(&wg.sema, synctestDurable)
207-
if wg.state.Load() != 0 {
208-
panic("sync: WaitGroup is reused before previous Wait has returned")
209-
}
207+
isReset := wg.state.Load() != 0
210208
if race.Enabled {
211209
race.Enable()
212210
race.Acquire(unsafe.Pointer(wg))
213211
}
212+
if isReset {
213+
panic("sync: WaitGroup is reused before previous Wait has returned")
214+
}
214215
return
215216
}
216217
}

0 commit comments

Comments
 (0)