Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists