]> Cypherpunks.ru repositories - gostls13.git/commit
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)
committerMichael Knyszek <mknyszek@google.com>
Fri, 23 Jun 2023 16:46:25 +0000 (16:46 +0000)
commit48dbb6227acf3ebc8ac21924567aa2b6d5064915
treeecc6d8f5099c32d1f23a80adc561b2359dc49e7f
parent3adcce5ae7203e9ee7bee93a4ad913a3145e682e
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>
src/runtime/proc.go
src/runtime/race/testdata/mop_test.go