diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp index 973888e9f..4de5d7e0e 100644 --- a/lib/base/timer.cpp +++ b/lib/base/timer.cpp @@ -296,6 +296,11 @@ void Timer::TimerThreadProc() break; auto it = idx.begin(); + + // timer->~Timer() may be called at any moment (if the last + // smart pointer gets destroyed) or even already waiting for + // l_TimerMutex (before doing anything else) which we have + // locked at the moment. Until our unlock using *timer is safe. Timer *timer = *it; ch::time_point> next (ch::duration(timer->m_Next));