Stack overflow

Technical Note 57348

Arkitekturer:

All

Komponent:

debugger

Uppdaterad:

2018-08-21 14:00

Introduction

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.

Background

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.)

Solution

Disable the warning message by removing the checkmark for Tools > Options... > Stack > '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.

Det här innehållet finns tyvärr inte på svenska.

Vår webbplats finns främst på vårt koncernspråk engelska, förutom det innehåll för investerare som vi är lagstadgade att kommunicera på svenska. Vi rekommenderar att du besöker vår globala webbplats på engelska för att få en bättre upplevelse.

Vi stöder inte längre Internet Explorer. För att få bästa möjliga upplevelse av iar.com rekommenderar vi att du uppgraderar till en modern webbläsare som Chrome eller Edge.