You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 18, 2023. It is now read-only.
I know this repository is no longer maintained, but I just want to record this somewhere for future people who might run into this.
Timers created with AfterFunc() which call back into the timer code by calling Timer.Close() can cause a deadlock. This is because Timer.Tick() calls the function while holding the mock time source's lock. Example test that reproduces the problem:
funcTestClockReentrantDeadlock(t*testing.T) {
mockedClock:=clock.NewMock()
timer20:=mockedClock.Timer(20*time.Second)
gofunc() {
v:=<-timer20.Cpanic(fmt.Sprintf("timer should not have ticked: %v", v))
}()
mockedClock.AfterFunc(10*time.Second, func() {
timer20.Stop()
})
mockedClock.Add(15*time.Second)
mockedClock.Add(15*time.Second)
}
I know this repository is no longer maintained, but I just want to record this somewhere for future people who might run into this.
Timers created with AfterFunc() which call back into the timer code by calling Timer.Close() can cause a deadlock. This is because Timer.Tick() calls the function while holding the mock time source's lock. Example test that reproduces the problem: