anonymous wrote on Wednesday, April 01, 2009:
Today, I’ve experienced a strange behaviour with FreeRTOS on STM32, using the SVN version and similar in 5.2.0 and 5.1.2.
I’ve added an ISR handler on USART3 receiving characters from a Zigbee module and sending them into a queue. Oddly enough, the system seems to loop indefinitely in vListInsert when queues are heavily used:
#0 0x20001d2a in vListInsert (pxList=0x20003c94, pxNewListItem=0x20002ab0) at …/…/Source/list.c:135
#1 0x200018f0 in vTaskPlaceOnEventList (pxEventList=0x20003c94, xTicksToWait=4294967295) at …/…/Source/tasks.c:1435
#2 0x20001226 in xQueueGenericReceive (pxQueue=0x20003c70, pvBuffer=0x20002cab, xTicksToWait=4294967295, xJustPeeking=0) at …/…/Source/queue.c:925
#3 0x20000b56 in zigbee_task (pvParameters=<value optimized out>) at adc.c:31
#4 0x00000000 in ?? ()
(gdb) fr 0
#0 0x20001d2a in vListInsert (pxList=0x20003c94, pxNewListItem=0x20002ab0)
at …/…/Source/list.c:135
135 for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
(gdb) p *pxIterator
$1 = {xItemValue = 3, pxNext = 0x20002ab0, pxPrevious = 0x20002ab0,
pvOwner = 0x20002a98, pvContainer = 0x20003c94}
As you see, pxIterator next and previous fields points onto itself, while its xItemValue is 3, which means that it’s not the latest item in the list (which should have an xItemValue of portMAX_DELAY, i.e. 0xffffffff). Of course, it loops indefinitely here (lines number may be a little different than from the original because of my added checks in an attempt to isolate this problem).
The ISR handler produces characters at a rate of approximately 1000 cps, and the consumer task consumes them as soon as possible.
For the context, there are no memory allocation after the scheduler has started, and all the previous object allocations have been checked. Nothing fancy here, only an annoying lockup. The more tasks there are in the system, the faster the lockup happens.
If you have any idea of what may happen here, I would be interested.