From b9fc5ecf684f5fe985dadae0c83510b75254ddb2 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Mon, 5 Jun 2017 16:08:46 +1000 Subject: [PATCH] freertos: Fix crash when waking task on CPU1 with scheduler disabled xPendingReadyList[1] was never initialised correctly, so if a task is added to this list (ie by xSemaphoreGiveFromISR() or similar) while scheduler is disabled, then it causes a null pointer dereference. Bug produces stack traces similar to: 0x40086e87: vListInsertEnd at /home/gus/esp/32/idf/components/freertos/./list.c:130 0x40084ba3: xTaskRemoveFromEventList at /home/gus/esp/32/idf/components/freertos/./tasks.c:3439 0x40083c54: xQueueGiveFromISR at /home/gus/esp/32/idf/components/freertos/./queue.c:2034 0x400f50a0: timer_group0_isr at /home/gus/esp/32/idf/components/freertos/test/./test_suspend_scheduler.c:27 0x40081d7d: _xt_lowint1 at xtensa_vectors.o:? --- components/freertos/tasks.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index d70a278b19..7bf51472c6 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -3508,7 +3508,10 @@ UBaseType_t uxPriority; vListInitialise( &xDelayedTaskList1 ); vListInitialise( &xDelayedTaskList2 ); - vListInitialise( &xPendingReadyList[ xPortGetCoreID() ] ); + vListInitialise( &xPendingReadyList[ 0 ] ); + if (portNUM_PROCESSORS == 2) { + vListInitialise( &xPendingReadyList[ 1 ] ); + } #if ( INCLUDE_vTaskDelete == 1 ) {