Stack overflow

Technical Note 57348



1/17/2012 2:34 PM


It some cases, C-SPY issues warnings such as ...

The stack 'CSTACK' is filled to 100% (4096 bytes used out of 4096). The warning threshold is set to 90%

... and there is no reason for the warning, as there should be plenty of free space in the stack.


When a project is created then the options are set to default values. One such default value is to enable the C stack(s) checking.

The possibility to check the ordinary C stack(s) is a good feature when writing and debugging an ordinary embedded application.

On the other hand, in an application with an RTOS, the C stack(s) checking will not work as intended. The C stack(s) checking is not able to 'understand' why the stack pointers are outside the 'known' stack areas. The reason for this situation is that the RTOS maintains and switches between the different stacks of the different tasks in the RTOS application.

The C stack(s) checking in C-SPY is integrated into IAR Embedded Workbench. (Earlier, the stack checking was handled by a C-SPY plugin.)


Disable the warning message by removing the checkmark for Tools > Options... > Debugger > 'Warn when stack pointer is out of bounds'

For an old version of IAR Embedded Workbench which uses the C-SPY stack plugin, disable the plugin by removing the checkmark for Project > Options > Debugger > Plugins > Stack

When using an RTOS, do not enable the C-SPY C stack(s) checking. Note that it might be possible to enable task stack checking in the plugin for the RTOS.

Other problem situations

If the application do not use an RTOS, the reason for the warning can be either ...

  • a correct warning, implying that changes are needed in the embedded application, or ...
  • the application is (at least partially) built without debug information. Note that the C stack(s) checking can not work as intended without debug information. In this situation disable the C stack(s) checking.

 All product names are trademarks or registered trademarks of their respective owners.

Related Tech Notes

© IAR Systems 1995-2016 - All rights reserved.