Stack overflow checking enhancement in 8.2.3

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

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

Stack overflow checking enhancement in 8.2.3

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

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

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