I’m using FreeRTOS 8.0.1 on PIC32MX.
I’m getting an address exception error which I’ve traced to the RTOS function uxListRemove(). The value of pxItemToRemove->pvContainer is initialized to NULL in vListInitialiseItem() and its value isn’t checked in uxListRemove() before it is dereferenced in these statements:
List_t * const pxList = ( List_t * ) pxItemToRemove->pvContainer;
/* Make sure the index is left pointing to a valid item. */
if( pxList->pxIndex == pxItemToRemove )
pxList->pxIndex = pxItemToRemove->pxPrevious;
The address exception occurs on the if statement — because in this instance, element pvContainer is still NULL. I don’t know why is hasn’t been initialized to something other than NULL. I only know that it hasn’t. 0x0000 is an invalid address in PIC32; RAM is referenced by virtual addresses beginning at 0xA0000000.
The value of ListItem_t pxItemToRemove immediately before the exception is:
xItemValue == 4
pxNext == 0xA0004BF8 (a valid RAM address)
pxPrevious == 0xA0004BF8
pvOwner == 0xA0004BE0
pvContainer == 0
I haven’t done anything that I would consider unusual. In fact, I have 2 nearly identical tasks executing in sequence. The first deletes itself before the second task is created. The first task executes fine. The second task will execute fine if I remove the first task (via commenting it out). But if it follows deletion of the first task, I get this address exception. I’ve checked that the idleTask is running to clean up deleted items. And I played with adjusting stack sizes, etc. before I traced this down to uxListRemove(). I appears to me that perhaps the value of this pointer “pvContainer” should be checked before it is dereferenced. I haven’t explored the RTOS kernel to see what’s actually being done here.