diff options
| author | Ian Lance Taylor <iant@golang.org> | 2019-04-11 14:20:54 -0700 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2019-10-23 07:43:18 +0000 |
| commit | ab3f1a23b6c29a110423d6fd6bf2b01fa62a6fb2 (patch) | |
| tree | 38e2a45179cd9748a8bad2099f32fbe3dc9a2e37 /src/runtime/proc.go | |
| parent | c824420d4744bd3e11128c000d88c24859602d46 (diff) | |
| download | go-ab3f1a23b6c29a110423d6fd6bf2b01fa62a6fb2.tar.xz | |
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>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index aa0a1fa2be..7d2ff2748b 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -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 } |
