Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Detecting stack overflow

Posted by Michael Carr on January 22, 2008
Is there a way port.c could be easily modified to detect an overflow of the stack area allocated for each task, probably during context switching? Perhaps it could do this in a "checked" build and trigger a reset or an assertion of some other kind. At the moment, it's difficult to predict/detect such software stack overflows unless I observe that my system starts behaving strangely and then spend a lot of time isolating the problem.

RE: Detecting stack overflow

Posted by Richard on January 22, 2008
It is fairly straight forward to prevent the scheduler writing over the end of the task stack as it knows where the stack start and end are.

It is a harder to *reliably* detect a task writing over the end of stack. A common technique is to put some known values at the end of the stack, then have the scheduler check that the known values are still there before switching to the next task - but this does not guarantee you will catch the fault as it is possible to write beyond the marker bytes without writing over the market bytes themselves.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner