23.3. Stack Overflow Detection

23.3.1. What is Stack Overflow?

In the simplest scenario, a stack overflow means that the application code consumed more stack space than the memory space allocated by the software developer. In some cases, depending on how the project sets up the memory layout, a stack overflow could corrupt the data in the heap memory space or even other global and static variables, leading to various types of program failures such as incorrect calculation results or program crashes (which might result in a HardFault exception).
In order to ensure correct operation of a program, we must ensure that there is sufficient memory space allocated for the stack and heap (e.g., space for dynamic memory allocation functions such as malloc()). ...

Get The Definitive Guide to ARM® Cortex®-M0 and Cortex-M0+ Processors, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.