-
Notifications
You must be signed in to change notification settings - Fork 8.1k
tests: stackprot: add guard area to ensure portable overflow behavior #95071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
tests: stackprot: add guard area to ensure portable overflow behavior #95071
Conversation
|
* MPU-protected region. Required to make the test independent of compiler- | ||
* specific stack frame layouts. | ||
*/ | ||
volatile char overflow_guard_area[32] = "Forcing Initialization!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need to make this __used
so compiler won't complain about this not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using __used
gives the following warning:
zephyr/tests/kernel/mem_protect/stackprot/src/main.c:87:11: warning: '__used__' attribute only applies to variables with non-local storage, functions, and Objective-C methods [-Wignored-attributes]
87 | volatile __used char overflow_guard_area[32] = "Forcing Initialization!";
| ^
zephyr/include/zephyr/toolchain/gcc.h:278:32: note: expanded from macro '__used'
278 | #define __used __attribute__((__used__))
| ^
1 warning generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... let's hope that compilers (other than those in Zephyr SDK) are not going to complain about it not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using __unused
makes both Zephyr SDK and ARCMWDT happy!
* MPU-protected region. Required to make the test independent of compiler- | ||
* specific stack frame layouts. | ||
*/ | ||
volatile char overflow_guard_area[32] = "Forcing Initialization!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... let's hope that compilers (other than those in Zephyr SDK) are not going to complain about it not being used.
@cfriedt Could you review this fix and the related issue? |
1b49504
to
10cd0c2
Compare
The stackprot test currently depends on compiler-generated stack frame layouts, which can vary between toolchains and optimization levels. This makes the overflow check fragile and may cause unintended faults. Add a small guard buffer in alternate_thread so the intentional overflow is always contained within the thread stack. This ensures the test behaves consistently across toolchains, architectures, and optimization settings. Signed-off-by: Mohamed Moawad <[email protected]>
10cd0c2
to
d0e57f3
Compare
|
The stackprot test currently depends on compiler-generated stack frame layouts, which can vary between toolchains and optimization levels. This makes the overflow check fragile and may cause unintended faults.
Add a small guard buffer in alternate_thread so the intentional overflow is always contained within the thread stack. This ensures the test behaves consistently across toolchains, architectures, and optimization settings.
Fixes: #95060