Glossary · Automation software engineering and architecture
Stack overflow
Also known as: Stack exhaustion
German: Stapelspeicherüberlauf
In programming, a stack overflow is an error in which a program uses more stack memory than is reserved for it, for example through deep recursion or large local variables, overwriting adjacent memory or triggering an exception.
- Software engineering
In one sentence
A stack overflow occurs when a program uses more stack memory than reserved, for example through deep recursion or large local data.
Example
A recursive search function in the gateway firmware overflows its task stack for a very long configuration list, and the device resets.
How it applies
- Engineering: Embedded coding guidelines restrict recursion and large local variables. Stack sizes per task are set from analysis or measurement with a safety margin.
- Verification: Worst-case stack analysis by static tools, stack painting and run-time monitoring detect insufficient stack sizes before they cause field failures.
- Documentation: Where users influence stack use, for example through nested function block calls in PLC code, the manual should state limits and the diagnostic shown on overflow.
Stack overflow vs. buffer overflow
A stack overflow exceeds the whole stack area. A Buffer overflow writes past the end of one buffer, which may be on the stack or elsewhere; buffer overflows are also a classic security vulnerability.