mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: add race detector support for new timers
Since the new timers run on g0, which does not have a race context, we add a race context field to the P, and use that for timer functions. This works since all timer functions are in the standard library. Updates #27707 Change-Id: I8a5b727b4ddc8ca6fc60eb6d6f5e9819245e395b Reviewed-on: https://go-review.googlesource.com/c/go/+/171882 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
c824420d47
commit
ab3f1a23b6
8 changed files with 98 additions and 7 deletions
|
|
@ -4166,6 +4166,21 @@ func (pp *p) destroy() {
|
|||
gfpurge(pp)
|
||||
traceProcFree(pp)
|
||||
if raceenabled {
|
||||
if pp.timerRaceCtx != 0 {
|
||||
// The race detector code uses a callback to fetch
|
||||
// the proc context, so arrange for that callback
|
||||
// to see the right thing.
|
||||
// This hack only works because we are the only
|
||||
// thread running.
|
||||
mp := getg().m
|
||||
phold := mp.p.ptr()
|
||||
mp.p.set(pp)
|
||||
|
||||
racectxend(pp.timerRaceCtx)
|
||||
pp.timerRaceCtx = 0
|
||||
|
||||
mp.p.set(phold)
|
||||
}
|
||||
raceprocdestroy(pp.raceprocctx)
|
||||
pp.raceprocctx = 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue