From 7f36144f8372d6fba159a6b621234517cb311fe0 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 10 Jul 2020 10:16:42 -0400 Subject: [PATCH] common/Timer: fixed invalid read from deleted object The std::conditional_variable will keep the provided reference and repeatedly dereference it even after the lock was dropped and re-acquired. This can lead to an invalid read if the associated schedule entry has been removed while waiting. Signed-off-by: Jason Dillaman --- src/common/Timer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/Timer.cc b/src/common/Timer.cc index 39ad4531915..bf050e6395a 100644 --- a/src/common/Timer.cc +++ b/src/common/Timer.cc @@ -107,7 +107,8 @@ void SafeTimer::timer_thread() if (schedule.empty()) { cond.wait(l); } else { - cond.wait_until(l, schedule.begin()->first); + auto when = schedule.begin()->first; + cond.wait_until(l, when); } ldout(cct,20) << "timer_thread awake" << dendl; } -- 2.39.5