From 8db1d0d1a36012371e5128a285b39c0770c1876e Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Fri, 4 Sep 2026 10:29:58 -0500 Subject: [PATCH] Add comment explaining HolderFromISR/SMP TOCTOU On SMP systems, xSemaphoreGetMutexHolderFromISR() is particularly difficult to use - note the footgun. See also espressif/esp-idf#18913 --- include/semphr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/semphr.h b/include/semphr.h index 7b44d78c058..69eb98c5ff9 100644 --- a/include/semphr.h +++ b/include/semphr.h @@ -1157,6 +1157,7 @@ typedef QueueHandle_t SemaphoreHandle_t; * If xMutex is not a mutex type semaphore, or the mutex is available (not held * by a task), return NULL. * + * Note: On SMP systems, the return value may be invalidated by other core(s). */ #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) #define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) )