mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
8a6c64f4fe
commit
8f74f9daf4
1 changed files with 4 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue