Crash in vListInsert due to xValueOfInsertion is equal to pxNext->xItemValue

deiti123 wrote on Saturday, November 15, 2014:

Hi, thx for the fast response - I’ll try to make my problem a little
bit more clear.

Here’s the code:

#define configMAX_PRIORITIES 5
Task 1 has a Priority of 2
Task 2 has a Priority of 3

In task 1, a message is sent to task 2, and then waits for the response.

//Make sure response queue is empty
while(xQueueReceive(CAN_SDO_ResponseQueue, &retval_u32, 0) == pdTRUE);

retval_u32 = CAN_SDO_STATE_START_TRANSFER;
xQueueSendToBack(CAN_SDO_TransferQueue, &retval_u32, 0); //Send to Task 2

xQueueReceive(CAN_SDO_ResponseQueue, &retval_u32, portMAX_DELAY) ← Here, the lock happens

This is where task 2 waits for work from task 1, after doing the work, it posts back into the CAN_SDO_ResponseQueue.

if(xQueueReceive(CAN_SDO_TransferQueue, &MsgAnswer_u32, 0) == pdTRUE)
//Do the work…
xQueueSendToBack(CAN_SDO_ResponseQueue, &MsgAnswer_u32, 0); //No delay needed, queue should be empty anyway…

So, just to make my problem a little bit clearer:
The lock happens exactly in this line in list.c - file:

for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
{
/* There is nothing to do here, we are just iterating to the
wanted insertion position. */
}

In the list, theres only one item (pointed to by pxNext and pxPrevious)
pxIterator->pxNext->xItemValue has a value of 3.
xValueOfInsertion has a value of 3.

When I understand the loop correctly, this causes a lock-up because the abort-condition is never met:

pxIterator->pxNext->xItemValue <= xValueOfInsertion

When xItemValue is representing the priority (of what?), then everytime an item with
same or higher priority should be placed in the list, it would cause a lock-up.

I just couldn’t figure out what this list ist actualy used for?
And what can i then do to avoid this lock-ups?

Best regards,
David