From e5d91131bc6481a9514951a3ffce27f4095592e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C4=8Cejchan?= Date: Thu, 12 Dec 2024 17:29:31 +0100 Subject: [PATCH] Fix race condition in Mutex::lock Fixes this problem: * defaultTask is stuck on xSemaphoreTake * PP triggers * the delay gets interrupted * we're still in the non-PP branch of the mutex::lock BFW-6418 --- src/freertos/mutex.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/freertos/mutex.cpp b/src/freertos/mutex.cpp index 5206229a9..edc77a50d 100644 --- a/src/freertos/mutex.cpp +++ b/src/freertos/mutex.cpp @@ -71,13 +71,9 @@ bool Mutex::try_lock() { } void Mutex::lock() { - // REMOVEME BFW-6418 - if (power_panic_mode_removeme) { - // In power panic mode, the defaultTask gets delays periodically aborted, which can result in mutexes takes failing - xSemaphoreTake(handle_cast(mutex_storage), portMAX_DELAY); - - } else { - if (xSemaphoreTake(handle_cast(mutex_storage), portMAX_DELAY) != pdTRUE) { + if (xSemaphoreTake(handle_cast(mutex_storage), portMAX_DELAY) != pdTRUE) { + // REMOVEME BFW-6418 + if (!power_panic_mode_removeme) { static_assert(INCLUDE_vTaskSuspend); // Since we are waiting forever and have task suspension, this should never happen. std::abort();