Introduction

This document describes how to recognize a stack overflow in PXROS-HR for ARM architecture v1.0.0.

In the PXROS-HR kernel, we leverage Memory Protection Units (MPUs) to protect task stacks and identify potential overflow conditions. Specifically, our approach involves using a dedicated MPU region to detect stack overflow. This becomes crucial when a stack overflow occurs during critical operations, such as the kernel saving the CPU/FPU context in a trap prologue or handling system calls.

If a stack overflow happens while the kernel is saving CPU/FPU context in a trap prolog (or during another system call), such a condition is detected. However, the system’s consistency cannot be guaranteed anymore. The typical recovery for such a condition is usually a safe system shutdown or restart. A stack overflow is exhibited like a generic Memory Management Fault (MMF), which can also be induced as a part of the handled (expected) task control flow. It is thus important for the application to distinguish between recoverable and non-recoverable MMF states.

Here’s the crucial part: users need to tell the difference between a problem they can recover from and one they can’t. This document serves as a guide, offering a reference implementation to detect and address stack overflow faults effectively.