death test failure

yen2008 wrote on Wednesday, April 09, 2008:

Hi, I have successfully ported FreeRTOS 4.7.1 on a microprocessor and all the demo are working.  Recently, I have ported the same version of FreeRTOS to a different toolchain.  The death test failed.  It runs for a while (vCreateTasks are created a few times) and then crashes.  I have increased substantially the stack size for the vCreateTasks (3Kbytes) and vSuicidalTask(1Kbytes) to determine if this could be stack overflow problem (I have 23Kbytes of heap memory and this is the only test running).  However, this does not seem to solve the problem.  What are the other possible causes for the test to fail please?

davedoors wrote on Wednesday, April 09, 2008:

Which compiler are you using, and which heap file are you including in your project (heap_1.c, heap_2.c or heap_3.c)?

yen2008 wrote on Wednesday, April 09, 2008:

I am using heap_3.c. The compiler is GCC

davedoors wrote on Wednesday, April 09, 2008:

GCC libraries are huge so stack issues could be an issue - although you say you have increased it already.

configTOTAL_HEAP_SIZE has no effect when using heap_3 so it could be that your linker script is not setting up a heap at all, or that the one it is setting up is very small.

Try switching to heap_2.c, in which case configTOTAL_HEAP_SIZE does dimension the heap.

yen2008 wrote on Wednesday, April 09, 2008:

Hi, I have verified that the linker script is correctly setting up the amount of heap memory requested. This is done by doing a loop malloc’ing 1K of memory, and the counter returned did reflect the heap memory specified in the linker script.  Anyway, I manage to run ALL the other demo tasks concurrently (except “death” demo).  Presumably this is sufficient to show the linker script is working.

I have looked further into this problem.  It looks like the vSuicidalTask did not manage to kill and free the tasks stacks.  Looking at the memory addresses allocated for the "pxNewTCB" and "pxNewTCB->pxStack" of each of the vSuicidalTask.  The "pxNewTCB->pxStack" of "SUICID1" and the "pxNewTCB" & "pxNewTCB->pxStack" of "SUICID2" are different each time these two tasks are created.  The program crashes when the "pxNewTCB->pxStack" of "SUICID1" overlaps with the "pxNewTCB" of "SUICID2".  I am not sure what are the causes the task was not deleted?

woops_ wrote on Wednesday, April 09, 2008:

Does the idle task ever run. It must run to free up the memory. Do you have any tasks running about the idle task that do not ever block.