[riot-notifications] [RIOT-OS/RIOT] riscv_common: Increase ISR stack size if DEVELHELP is enabled (#16448)
notifications at github.com
Wed May 5 11:25:24 CEST 2021
### Contribution description
The `handle_trap()` implementation for `riscv_common` includes the following debugging code if `DEVELHELP` is enabled:
This code is executed on the ISR stack and not on any standard RIOT thread stack. The stack size of this ISR stack is defined in the ldscript for `riscv_common` as follows:
Unfortunately, 256 Bytes is insufficient for newlib `printf()` usage and thus causes a stack overflow on the ISR stack if `DEVELHELP` is enabled and this code path in `handle_trap()` is triggered. One solution to avoid this problem is to increase the size of the ISR stack if `DEVELHELP` is enabled, this is the solution this PR proposes. Alternatively, it would also be possible to simply remove the `printf()` invocations from `handle_trap()`.
### Testing procedure
I discovered this through an external tool I am currently working on which I cannot share at this point. Similar to #16395, this bug can be confirmed independently by checking the value of the `sp` register after each instruction in `handle_trap()` using GDB. I am not sure if there is any interest in these ISR stack overflow edge cases but I wanted to document this anyhow in case some else runs into them by accident. If you don't consider it worthwhile to fix these edge cases let me know.
### Issues/PRs references
This is similar to the aforementioned issue #16395 which is also a stack overflow on the ISR stack which occurs due to `printf()` usage on this stack. This issue is, however, not fixed by this PR as `ENABLE_DEBUG` can be enabled independent of `DEVELHELP`.
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* riscv_common: Increase ISR stack size if DEVELHELP is enabled
-- File Changes --
M cpu/riscv_common/Makefile.include (7)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications