vApplicationStackOverflowHook provides a very simple way of eliminating most of the oddball behavior and halting the application. When enabling configCHECK_FOR_STACK_OVERFLOW #define in FreeRTOSConfig.h, any time a stack overflow is detected by FreeRTOS, vApplicationStackOverflowHook will be called.
There are two potential values for configCHECK_FOR_STACK_OVERFLOW:
- #define configCHECK_FOR_STACK_OVERFLOW 1: Checks the stack pointer location upon task exit.
- #define configCHECK_FOR_STACK_OVERFLOW 2: Fills the stack with a known pattern and checks for the pattern upon exit.
The first method checks the task stack pointer as the task exits the running state. If the stack pointer is pointing to an invalid location ...