]> Cypherpunks repositories - gostls13.git/commit
runtime: fix spurious race using Ticker.Reset
authorRuss Cox <rsc@golang.org>
Fri, 1 Mar 2024 01:14:32 +0000 (20:14 -0500)
committerGopher Robot <gobot@golang.org>
Fri, 8 Mar 2024 22:34:15 +0000 (22:34 +0000)
commit24fa7544b08f998ed3dd857342dc7787924276a1
treeb97df78dd3b56d24fdd7e241140f1dd494a66b02
parenta21b275a5b3e1d72e533b681406d88f6507f17bb
runtime: fix spurious race using Ticker.Reset

Ticker.Reset was added in CL 217362 in 2020.
It added the runtime helper modTimer, which is
analogous to startTimer and resetTimer but for tickers.
Unlike those, it does not contain a racerelease, which
means that code synchronizing by starting a ticker
will be diagnosed with a spurious race.

Add racerelease to modTimer and add tests of all
three racereleases (in startTimer, resetTimer, and modTimer).

Also do not call time.resetTimer from elsewhere in runtime,
since that function is only for package time. Use t.reset instead.

For #33184.

Change-Id: Ie40c1ad24911f21e81b1d3cc608cf086ff2bc83d
Reviewed-on: https://go-review.googlesource.com/c/go/+/568340
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/race/testdata/time_test.go [new file with mode: 0644]
src/runtime/time.go