This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Getting Stack Overflow while sending HTTP GET Request using TI-RTOS

Other Parts Discussed in Thread: EK-TM4C1294XL, CC3100, TM4C1294NCPDT

Hi,

I am using CCS Version: 6.1.0.00104, tirtos_tivac_2_12_01_33, TivaWare_C_Series-2.1.1.71 on EK-TM4C1294XL baord.
I took HTTP Get Example from Demo. I have done the following modifications:
- Added a periodic timer to run at every 10 Sec.
- Created a static task 'usrTask' with priority as '-1'
- Whenever Timer expires it changes 'usrTask' priority to '1'.
- for 'usrTask' created function as 'usrTaskRt()'. This function calls netIPAddrHook() and than priority of 'usrTask' is set to '-1' again.
- there is no change in netIPAddrHook(). It creates HTTP task and do a GET request to get data from server.

I checked with HOSTNAME = api.openweathermap.org and REQUEST_URI = data/2.5/weather?q=London,uk. IP is resolved as IP = 162.243.58.21. Board is continuously doing GET requests, fetching data and displays it.
Than I created a local server which sends GMT time as unix time stamp. HOSTNAME = 192.168.0.100, REQUEST_URI = /app/service/time and IP = 192.168.0.100. Board is sending GET request and displays time. But after some executions I am getting Stack Overflow error as below:
l.Task: line 380: E_spOutOfBounds: Task 0x20000468 stack error, SP = 0x2000214c.
xdc.runtime.Error.raise: terminating execution

I only made changes in HOSTNAME, REQUEST_URI and IP there are no other changes in the code. Does anyone know why stack overflow is happening while communication with local server and not with api.openweathermap.org ? Also Increasing Stack Memory allocation is not solving problem.

And thing I observed is the time frame for Stack overflow is within 2-4 min time range irrespective of the Timer timeout settings. I changed timeout to 2 sec, 5 sec, 10 sec, 15 sec, 30 sec to verify but always above error is occurring in 2-4 min time frame.

Also if httpTask() is called as a function than HTTPCli_connect() always failing. So why httpTask() function requires to be called as a Task?
Attached is code, screen shot of the response from local server and api.openweathermap.org.

Thanks,
Bhavesh

6763.httpget_TivaTM4C1294NCPDT1.zip

  • Hi Bhavesh,

    Why are you creating task repeatedly without deleting existing one?

    Regards,

    Aashish

  • Hi Aashish,

    I added following lines of code after HTTPCli_destruct(&cli);
    Task_destruct;
    Task_delete;
    Task_deleteTerminatedTasks;
    But I am still getting Stack Overflow error after sometime. Also task is being removed after execution that I have checked in ROV. Is this issue because of dynamic task created by netIPAddrHook() to invoke httpTask()? 
    And as mentioned earlier, if httpTask() is not called from netIPAddrHook() than HTTPCli_connect() is always failing. So why HTTPCli_connect() requires to be called from netIPAddrHook() only?
    In .cfg file System Stack and Heap Size allocated is 10KB and 20KB respectively.

    Thanks,
    Bhavesh

  • Hi Bhavesh,

    Are you using CC3100 with Tiva board?

    Regards,

    Aashish

  • Nope. Processor is TM4C1294NCPDT and board is EK-TM4C1294XL.
  • Moving to "TivaC" forum

    Regards,
    Gigi Joseph.

  • Hello Bhavesh,

    Did you check by increasing the Stack Size? There is a post on the forum where it has been shown that the stack size on the RTOS example must be increased.

    Regards
    Amit
  • Hi Amit,
    I tried to increase stack size in .cfg file BIOS -> Runtime -> System stack size to 10K from 2048 and Heap size to 20K from 0. Also changed C Stack from Project Properties to 20K.
    But Increasing the stack size is still getting same 'Stack Overflow' error.
    What is the recommended size of Stack?
    Thanks,
    Bhavesh
  • Hi Amit,

    some observation I got from ROV are below:
    - There is a task which is calling dhcpState(). Stack Size allocated to this task is 1280 bytes. And with every GET or POST request it is increasing and after some time getting Stack Over flow error.
    - httpTask() has to be called via netIPAddrHook() only, otherwise HTTPCli_connect() is failing.
    - Sometimes httpTask() is not deleted from the queue, even if Task_destruct is called within task. And when netIPAddrHook() tries to create httpTask() again, we are getting Stack Overflow error.

    Is there any way to execute httpTask() without being called from netIPAddrHook()?

    Thanks,
    Bhavesh

  • Hi Bhavesh,

    What is the stack size of your 'usrTask'?

    Can you take a screen shot of ROV's Task view (detailed tab) when this issue happens?

    If you can see that the stack overflow is with your usrTask, you can try increasing the stack size of that specific task by adding the following bolded line of code to your *.cfg file:

    task0Params.instance.name = "usrTask";
    task0Params.priority = -1;
    task0Params.stackSize = 4096;
    Program.global.usrTask = Task.create("&usrTaskRt", task0Params);

    Bhavesh Patel said:
    Also if httpTask() is called as a function than HTTPCli_connect() always failing. So why httpTask() function requires to be called as a Task?

    The HTTP Client module (in this example) uses the NDK as its underlying TCP/IP stack.  HTTPCli_connect() makes sockets calls [specifically, to socket() and connect()].  The NDK requires that such socket calls be made within Task context.

    Steve