diff --git a/components/pthread/pthread.c b/components/pthread/pthread.c index 2250c4075..ef87e8f22 100644 --- a/components/pthread/pthread.c +++ b/components/pthread/pthread.c @@ -591,7 +591,12 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex) return EBUSY; } + // FreeRTOS mutex must not be deleted while taken (breaks priority inheritance): + vTaskSuspendAll(); + pthread_mutex_unlock(mutex); vSemaphoreDelete(mux->sem); + xTaskResumeAll(); + free(mux); return 0;