diff options
| author | Jelle van den Hooff <jelle@vandenhooff.name> | 2023-06-21 18:28:05 -0700 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2023-06-23 16:46:25 +0000 |
| commit | 48dbb6227acf3ebc8ac21924567aa2b6d5064915 (patch) | |
| tree | ecc6d8f5099c32d1f23a80adc561b2359dc49e7f /src/runtime/proc.go | |
| parent | 3adcce5ae7203e9ee7bee93a4ad913a3145e682e (diff) | |
| download | go-48dbb6227acf3ebc8ac21924567aa2b6d5064915.tar.xz | |
runtime: set raceignore to zero when starting a new goroutine
When reusing a g struct the runtime did not reset
g.raceignore. Initialize raceignore to zero when initially
setting racectx.
A goroutine can end with a non-zero raceignore if it exits
after calling runtime.RaceDisable without a matching
runtime.RaceEnable. If that goroutine's g is later reused
the race detector is in a weird state: the underlying
g.racectx is active, yet g.raceignore is non-zero, and
raceacquire/racerelease which check g.raceignore become
no-ops. This causes the race detector to report races when
there are none.
Fixes #60934
Change-Id: Ib8e412f11badbaf69a480f03740da70891f4093f
Reviewed-on: https://go-review.googlesource.com/c/go/+/505055
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 3cecd1a057..9fd200ea32 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4570,6 +4570,7 @@ func newproc1(fn *funcval, callergp *g, callerpc uintptr) *g { pp.goidcache++ if raceenabled { newg.racectx = racegostart(callerpc) + newg.raceignore = 0 if newg.labels != nil { // See note in proflabel.go on labelSync's role in synchronizing // with the reads in the signal handler. |
