Quality RTOS & Embedded Software

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


Loading

Stack overflow checking enhancement in 8.2.3

Posted by kristio on February 12, 2016

StackMacros.h:

Is there a particular reason why the stack overflow check (configCHECKFORSTACKOVERFLOW > 1) now only checks for the 16 last bytes of stack (4 x uint32t) as opposed to 20 bytes in previous versions?

And I see when portSTACK_GROWTH > 0, it still checks for 20 bytes with the earlier memcmp() usage. Intended?

I find this additional stack protection level useful and worth the cost. However, in effect it actually reduces the available stack; because if to be useful one has to implement vApplicationStackOverflowHook() that probably should show some sort of warning and halt/reboot if using that last part of the stack.

If I were to suggest something: The additional 16 (or 20) bytes this feature uses of the stack, should be added (when this feature is enabled) to stack allocation when creating stack. Simply because it is not really available for use. However, I see that it may be a bit of a consistency conflict in upcoming support for static tasks stacks; where freeRTOS would not be able to control this.


Stack overflow checking enhancement in 8.2.3

Posted by rtel on February 12, 2016

Efficiency was the only reason - there is not much in it either way.


Stack overflow checking enhancement in 8.2.3

Posted by kristio on February 12, 2016

Thanks for your swift reply.

The discussion on whether to check for 16 or 20 (or another number) last bytes can lead to an endless discussion, as none of the stack checks are 100% safe. The reason I asked is that I am making use of that knowledge when displaying unused stack amount for tasks; not including that buffer zone. In order to not give a false impression that more bytes are available than there actually is. (I trigger a controlled message and reboot if detecting writes into that zone.) But the knowledge of the size of the buffer zone is not an exported item, and thus I need to (re)define it manually outside FreeRTOS. That is why I was a bit interested.

Why is the old way with memcmp (20 bytes) still used on stacks that grows upwards? Not that I think I have ever used such a target...


Stack overflow checking enhancement in 8.2.3

Posted by rtel on February 12, 2016

Why is the old way with memcmp (20 bytes) still used on stacks that grows upwards? Not that I think I have ever used such a target...

...because, thus far, the new method has only been tested on targets where the stack grows down, whereas the older method was tested on both.


Stack overflow checking enhancement in 8.2.3

Posted by dumarjo on February 12, 2016

Hi,

In yout config file you add this define to enable custom function to task.c file. FREERTOSMODULETEST

This will include a new file called "taskstestaccess_functions.h". In this file you can add your function that have access to the task.c scope file.

We already add some custom function to get stack pointer position, stack size, etc...

regards

Jonathan


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 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