From b54ca67de9b5900c7ed11bef323c7b4e5a0339b6 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 15 Mar 2019 13:15:39 +0100 Subject: [PATCH] lockstep_scheduler: check if mutex is still valid It turns out that we can fix the unit tests of the lockstep_scheduler just by checking if `passed_lock` is not `nullptr`. Without this check, the unit tests segfaulted. --- .../include/lockstep_scheduler/lockstep_scheduler.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h b/platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h index d9c8c6daee..06726e1b17 100644 --- a/platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h +++ b/platforms/posix/src/lockstep_scheduler/include/lockstep_scheduler/lockstep_scheduler.h @@ -29,7 +29,10 @@ private: // This destructor gets called as part of thread-local storage cleanup. // This is really only a work-around for non-proper thread stopping. Note that we also assume, // that we can still access the mutex. - pthread_mutex_unlock(passed_lock); + if (passed_lock) { + pthread_mutex_unlock(passed_lock); + } + done = true; }