FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [February 2016 Threads] Stack overflow checking enhancement in 8.2.3Posted 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.3Posted 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.3Posted 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.3Posted 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.3Posted 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
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|