nickm2018 wrote on October 08, 2018:
This question is more focused on the FreeRTOS implementation and not a AWS library question.
I am running a custom platform using the heap_3 configuration.
In my application, I am trying to reset the OTA connection (disconnect and reconnect) but when I call OTA_AgentShutdown, I end up hitting an assert in FreeRTOS queue. The problem appears to be related to the vEventGroupDelete call in the OTA agent thread of aws_ota_agent.c, specifically the following lines:
prvAgentShutdownCleanup( &xMsgMetaData );
vEventGroupDelete( xOTA_Agent.xOTA_EventFlags );
I stepped into the code with my debugger and the eventGroup is valid and not null.
Call tree
vEventGroupDelete
–> vPortFree
–> free
–> some platform library call
–> __malloc_lock (heap_3.c)
–>xSemaphoreTakeRecursive
–>xQueueGenericReceive
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
Going back through the call stack, configUSE_NEWLIB_MALLOC_LOCK is defined to 1, which should suspend the scheduler through vTaskSuspendAll. If I step into the xTaskGetSchedulerState(),
xSchedulerRunning = 1, so scheduler is started
uxSchedulerSuspended = 1, so scheduler is suspended.
So xTaskGetSchedulerState returns taskSCHEDULER_SUSPENDED and xTicksToWait is set to 0xFFFFFFFF, which means the assert will fail.
Seems like there are two calls to vTaskSuspendAll in the call tree, one in vPortFree and the other in vEventGroupDelete. Is this a FreeRTOS configuration issue? It seems like the scheduler cannot be suspended for xQueueGenericReceive to run.