Free RTOS parameter CHECK_FOR_STACK_OVERFLOW seems not to work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 12:31 AM - last edited on ‎2025-05-13 9:55 AM by mƎALLEm
Hello.
I bought Riverdi board and start to develop my code.
I found in FREERTOS_M7 Config parameters RTOS CHECK_FOR_STACK_OVERFLOW.
Documentation says
CHECK_FOR_STACK_OVERFLOW
Parameter Description:
FreeRTOS provides two optional mechanisms that can be used to assist in stack overflow detection and debugging.
- when CHECK_FOR_STACK_OVERFLOW is set to 1 (option1), one mechanism is used
- when CHECK_FOR_STACK_OVERFLOW is set to 2 (option2), both mechanisms are used.
If CHECK_FOR_STACK_OVERFLOW is not set to 0 (Disabled), the application must provide a stack overflow hook (or callback) function: void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName );
The kernel will call that stack overflow hook whenever a stack overflow is detected
Note: when set to 1 or 2, a function with an empty body is generated in the freertos.c file (to be completed by the user)
So I set CHECK_FOR_STACK_OVERFLOW = 1, trigger a stack overflow by an infinite recursive and set a bkpoint in
But when I run the code I just reach HardFault_Handler
What am I wrong ?
Solved! Go to Solution.
- Labels:
-
FreeRTOS
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 6:56 AM
Not in this case.
The check is done when tasks are switched which happens on the millisecond scale. If the overflow happens before then and a hard fault is produced, it will not be prevented. Calling a function recursively will overflow the stack very fast. It is not a magic solution that works all the time without limitation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 5:00 AM
See here for how this works. It only checks when tasks are switched.
FreeRTOS stack usage and stack overflow checking - FreeRTOSâ„¢
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 6:22 AM
Ok, but I expect that if I call recursively a function without any limit as soon as far that stack will going to saturation and I expect that the FreeRTOS signal me that condition if I select one of the option available.
I am right ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 6:56 AM
Not in this case.
The check is done when tasks are switched which happens on the millisecond scale. If the overflow happens before then and a hard fault is produced, it will not be prevented. Calling a function recursively will overflow the stack very fast. It is not a magic solution that works all the time without limitation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 11:31 PM
