-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
hey there. while running FreeRTOS SMP 11.2.0 on SDK version 2.2.0 with static allocation enabled, I ran into an issue where calling cyw43_arch_deinit
from a FreeRTOS task would cause FreeRTOS to throw an assertion failure and hard fault:
assertion "( ( uint8_t * ) ( pxLink ) >= &( ucHeap[ 0 ] ) ) && ( ( uint8_t * ) ( pxLink ) <= &( ucHeap[ (128*1024) - 1 ] ) )" failed: file "/home/vogon/work/ais-epaper/build/freertos_kernel-src/portable/MemMang/heap_4.c", line 368, function: vPortFree
I think the series of events which precipitates this assertion failing are:
async_context_freertos_deinit
callsxTimerDelete
on the async context's associated timer, which enqueues an asynchronous timer delete command for the timer task.async_context_freertos_deinit
continues executing past thememset
at the end of the function.- the timer task is scheduled and receives the command from
async_context_freertos_deinit
to delete the timer. prvProcessReceivedCommands
checkspxTimer->ucStatus
, which has been cleared to 0, and decides the timer was dynamically allocated.vPortFree
notices that the statically-allocated timer isn't in a heap block and panics.
I've verified that commenting out the memset at the bottom of async_context_freertos_deinit
(which seems to be redundant with a memset at the top of async_context_freertos_init
) prevents the crash from happening.
I've uploaded a gist of the app I'm running (with all the commented-out code removed but otherwise not cleaned up), as well as my FreeRTOSConfig.h and CMakeLists.txt: https://gist.github.com/vogon/4c08fdd31a565609d02cb2534a4386bd