]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] runtime: set raceignore to zero when starting a new goroutine
authorJelle van den Hooff <jelle@vandenhooff.name>
Thu, 22 Jun 2023 01:28:05 +0000 (18:28 -0700)
committerCarlos Amedee <carlos@golang.org>
Thu, 29 Jun 2023 15:53:25 +0000 (15:53 +0000)
commitc4590af14915e7f0aef40da4dec824eb8e3a419b
treed0dc3f1f006293bfdfa06f952f91816bbfa93358
parent16b198519bba9fefbf153f33d1fc198229b8c35c
[release-branch.go1.19] 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.

For #60934
Fixes #60948

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>
(cherry picked from commit 48dbb6227acf3ebc8ac21924567aa2b6d5064915)
Reviewed-on: https://go-review.googlesource.com/c/go/+/505675
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
src/runtime/proc.go
src/runtime/race/testdata/mop_test.go