Stack overflow prevention (STOP) technology
Prevent stack overflows before they compromise system stability
- Compiler-based protection without code changes
- Compatible with any RTOS
- Minimal impact on code size and performance
Overview
SEGGER's Stack Overflow Prevention (STOP) technology uses compiler-inserted stack limit checks to prevent stack overflows during application execution. Integrated into the optimizing SEGGER Compiler, STOP can be enabled without modifying the application code.
STOP can be evaluated using the demonstration project included in the Embedded Studio simulator.
More technical details, source listing, and examples of how STOP works are available on our STOP wiki page.
Key features
- Prevents stack overflow
- Easily enabled in any application
- Can be used with any RTOS
- Very low impact on size and speed
System insight
With STOP, the compiler calls a stack limit-check routine wherever necessary, before adjusting the stack pointer. This way, all stack overflows are prevented. The protection also covers the standard C library. If a stack overflow has been prevented, the system can enter a safe state and recover.
STOP protects all stacks in the system, including the process stack as well as the "main" stack used for interrupts.It can be used with any RTOS, provided the RTOS updates the stack-limit variable on a context switch.
Detection and overflow
A stack overflow can cause all kinds of failures in an embedded system, from hard-to-detect, seemingly random miscomputations to severe malfunctions or even crashes.
To compute the required stack size at compile time is not possible for most systems, as function pointers make an analysis at compile or link time impossible. In addition, every program modification, compiler optimization or change of compiler can change the stack requirements, making run time stack checking a must.
Performance and resource usage
STOP has a very low impact on size and speed. It adds about 2 to 5 % to code size and execution time, which typically does not have a significant impact on the performance of the system.
Supported architecture
STOP is currently available for Thumb-2 architectures, such as Cortex-M4, Cortex-M7, Cortex-A9, and Cortex-A15.
On ARMv7M architectures, STOP is ready to use in Embedded Studio with a single project option switch.
