Infinite loop

nobody wrote on Wednesday, September 14, 2005:

        pxPreviousBlock = &xStart;
            pxBlock = xStart.pxNextFreeBlock;
            while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) )
            {
                pxPreviousBlock = pxBlock;
                pxBlock = pxBlock->pxNextFreeBlock;
            }

Richard,

I’m still having this looping problem within heap2 in the above code.  It does appear to occur randomly.   I’ve tried everything to understand this, except for beating my head against a wall :slight_smile:

If I step through the above code, the value of pxBlock is always the same.  IE the linked list seems to be linked to the same cell.

My guess is that there is a critical area somewhere which is not protected and an interrupt has sneaked it…  Any ideas.

Thanks
Phil

rtel wrote on Wednesday, September 14, 2005:

Thats interesting.  I will have to run through the test code to re-familiarise myself with this function to see if I can work out how this could happen.

Before you enter the loop pxBlock is set to the address of xStart.  Is this still the case when you start looping forever, or does the loop execute correctly for a bit before getting stuck.  Alternatively, If you are able to inspect xStart from within your debugger, then does xStart.pxNextFreeBlock point back to xStart?

nobody wrote on Wednesday, September 14, 2005:

Will check and see.

Phil