Bug in FreeRTOS??

konoppo wrote on Monday, March 23, 2009:

Hi!!

   I noticed a strange thing! When 3 tasks have been started without enough free stack system crashed! I didn’t return from last xTaskCreate! System crashed in prvAllocateTCBAndStack function - it didn’t come out from:
    memset( pxNewTCB->pxStack, tskSTACK_FILL_BYTE, usStackDepth * sizeof( portSTACK_TYPE ) );

When I simply comment this line (it is useful only when debuging) system start working correctly! It means it returned an error code from xTaskCreate function insted of hang up in this function!!

Is it a kind of bug?? Or maybe I made something wrong??

I use FreeRTOS on LPC2364 ARM7 microcontroller.

Regards
Konoppo

davedoors wrote on Monday, March 23, 2009:

Most likely your linker script is wrong, or the startup code is not correctly initializing variables.

konoppo wrote on Monday, March 23, 2009:

For what should I pay attention in linker script or in startup code?? In my opinion both are correct but maybe I missed something ;)…

rtel wrote on Monday, March 23, 2009:

If there is not enough heap space to create a task then pvPortMalloc() will return NULL and xTaskCreate() will never call memset().  Do you mean without enough stack, or do you mean without enough heap?  (you say stack).

Which heap implementation are you using, heap_1, heap_2 or heap_3?

Which compiler are you using?

Regards.

konoppo wrote on Monday, March 23, 2009:

OK, thanks for suggestion!! The USER_MODE stack size was only 2kB, when the total cheap size for freeRTOS was 4kB ;)… When I changed it everything is OK now :)…

konoppo wrote on Monday, March 23, 2009:

I use heap_2, and I should say “heap” instead of stack ;)… But problem Was in stack size, I think… When I increased it - everything is OK now. But I think it’s not good idea, that xTaskCreate() call memset in this situation and crash system (my uC went to address like 0xa5000000 and NOPs instruction)…

Regards
Konoppo

rtel wrote on Monday, March 23, 2009:

Are you suggesting each line if FreeRTOS should check the user has not overflowed the stack before executing - even before the scheduler has been started?

Regards.

konoppo wrote on Monday, March 23, 2009:

OK, you are right, my suggestion was a bit stupid ;)… For me it wasn’t obvious that freeRTOS uses a Supervisor Stack Size…

konoppo wrote on Monday, March 23, 2009:

OK, please, tell me - which memory is used by freeRTOS for “heap”?? It’s a free RAM (bss_section) or it’s stored in the stac region?? I thought that heap uses the stack region but now I think that it’s stored in BSS section (like any other variable)… I use GCC…