# Stack overflow while using max stack depth

**URL:** <https://forums.freertos.org/t/stack-overflow-while-using-max-stack-depth/6236>\
**Category:** Kernel\
**Created:** [October 21, 2016, 4:22pm UTC](https://forums.freertos.org/t/stack-overflow-while-using-max-stack-depth/6236 "2016-10-21T16:22:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 21, 2016, 4:22pm UTC](https://forums.freertos.org/t/stack-overflow-while-using-max-stack-depth/6236/1 "2016-10-21T16:22:25Z")

</div>

**[nateslager93](https://sourceforge.net/u/nateslager93/)** wrote on [Friday, October 21, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a735e7e8/#2f8e):

I have a task that is created with max stack depth 256kb (max value for data type short = 65535) . But it is still overflowing. I cannot alter the task to use less ram. Is there a way to increase stack depth beyond this for freertos v.8.2.3 (only version supported by Xilinx)? Note that xTaskCreateStatic (which takes in 32 bit stack depth field, instead of 16) isn’t availabe before freertos v9.0.0.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 21, 2016, 4:32pm UTC](https://forums.freertos.org/t/stack-overflow-while-using-max-stack-depth/6236/2 "2016-10-21T16:32:23Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, October 21, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a735e7e8/#2f8e/19c9):

The data type dates back a number of years, and for backward  
compatibility can’t be changed - although as you point out the newer  
function doesn’t have the same issue. You will not encounter any  
problems if you simply edit the code to make it a uint32\_t though.  
Don’t forget to edit the prototype in task.h too.

It won’t help you know, but I will change this so the data type is  
instead a macro that defaults to uint16\_t for backward compatibility,  
but can be overridden by defining the macro in the FreeRTOSConfig.h file.

I suppose another option would be to find the path in your code that is  
using so much stack, and see if you can instead allocate the memory from  
the heap (remembering to give it back again at the end of the function,  
of course).

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 27, 2016, 3:54pm UTC](https://forums.freertos.org/t/stack-overflow-while-using-max-stack-depth/6236/3 "2016-10-27T15:54:54Z")

</div>

**[nateslager93](https://sourceforge.net/u/nateslager93/)** wrote on [Thursday, October 27, 2016](https://sourceforge.net/p/freertos/discussion/382005/thread/a735e7e8/#ff43):

Thank you! This worked!
