aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-12-01 17:24:33 -0500
committerMichael Pratt <mpratt@google.com>2020-12-03 21:21:23 +0000
commitb635e4b808bf45ebd66e9f687e18b9af6bd634c1 (patch)
treea4568a92d6cb9ab0afd7ec8f28433a636d260529
parent4eb7ceba067cf4f3851f2eaf63c9929386594adf (diff)
downloadgo-b635e4b808bf45ebd66e9f687e18b9af6bd634c1.tar.gz
go-b635e4b808bf45ebd66e9f687e18b9af6bd634c1.zip
time, runtime: don't set timer when = 0
timer when == 0, in the context of timer0When and timerModifiedEarliest, is a sentinel value meaning there are no timers on the heap. TestCheckRuntimeTimerOverflow reaching into the runtime to set a timer to when = 0 when it is otherwise not possible breaks this invariant. After golang.org/cl/258303, we will no longer detect and run this timer, thus blocking any other timers lower on the heap from running. This manifests as random timers failing to fire in other tests. The need to set this overflowed timer to when = 0 is gone with the old timer proc implementation, so we can simply remove it. Fixes #42424 Change-Id: Iea32100136ad8ec1bedfa77b1e7d9ed868812838 Reviewed-on: https://go-review.googlesource.com/c/go/+/274632 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Pratt <mpratt@google.com>
-rw-r--r--src/runtime/time.go2
-rw-r--r--src/time/internal_test.go10
2 files changed, 2 insertions, 10 deletions
diff --git a/src/runtime/time.go b/src/runtime/time.go
index 75b66f8492..83d93c5686 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -23,6 +23,8 @@ type timer struct {
// Timer wakes up at when, and then at when+period, ... (period > 0 only)
// each time calling f(arg, now) in the timer goroutine, so f must be
// a well-behaved function and not block.
+ //
+ // when must be positive on an active timer.
when int64
period int64
f func(interface{}, uintptr)
diff --git a/src/time/internal_test.go b/src/time/internal_test.go
index 35ce69b228..e70b6f34de 100644
--- a/src/time/internal_test.go
+++ b/src/time/internal_test.go
@@ -53,18 +53,8 @@ func CheckRuntimeTimerOverflow() {
t := NewTimer(1)
defer func() {
- // Subsequent tests won't work correctly if we don't stop the
- // overflow timer and kick the timer proc back into service.
- //
- // The timer proc is now sleeping and can only be awoken by
- // adding a timer to the *beginning* of the heap. We can't
- // wake it up by calling NewTimer since other tests may have
- // left timers running that should have expired before ours.
- // Instead we zero the overflow timer duration and start it
- // once more.
stopTimer(r)
t.Stop()
- resetTimer(r, 0)
}()
// If the test fails, we will hang here until the timeout in the