Developer Portal Community

    Showing results for 
    Search instead for 
    Did you mean: 

    STACK OVERFLOW error when using freeRTOS


    STACK OVERFLOW error when using freeRTOS

    Hi All,

    I am trying to run the task template found here:

    Initially it was working fine, then I tried to change the 'myTaskFunction' as follows:

    void pParameters;

         for (int i = 0 ; i < 2 ; i ++){

                printf("Task fired\n\r");



    This printed once, then I recieved a stackoverflow error. I then deleted this and i'm trying to run the template as is, without modifying the code, and I am recieving the following in the console:

    INFO | Connecting to XDK device 'XDK Device 1' in port 'COM5'...
    INFO | Connection to port 'COM5' established
    INFO | XDK DEVICE 1: Task fired
    INFO | XDK DEVICE 1: ----- STACK OVERFLOW -----Task Name:My Task-----Current Task Handle:0x200044e8
    ERROR | Exception occured: Timeout: Ready Response took longer than 10000 ms
    at at

    I thought the stack would be reset each time the task is created, therefore it should be reset by running the project, however this did not happen. The things I have done to try and fix this error are:

    - Power cycle the XDK and cycle the project to try and fix it.

    - Run the template in a different project

    - Close XDK-Workbench and reopen

    - Restart my computer (I know, I didnt expect this to fix it either)

    None of these worked. I tried running a different project template that doesn't use freeRTOS, and that worked fine. Any tips on how I can fix this problem?






    1 REPLY 1
    Long-established Member

    Re: STACK OVERFLOW error when using freeRTOS

    Hi Stallion,

    task functions work in FreeRTOS as an infinite loop (or at least, you should not exit the stack area alloted to the instance of the task executing function) and it looks like the code will step out of the function after completing the loops i==0 and i==1. FreeRTOS does not have automatic resource handling, so if the task was not deleted or stopped, the task will continue to step into unknown territory. 

    Best regards,