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
GCC 13 compiler warning in kernel/userspace.c #72430
Labels
area: Kernel
area: Userspace
Userspace
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Comments
Hi @davidschneider-cpi! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
aescolar
changed the title
GCC 13 compiler warning
GCC 13 compiler warning in kernel/userspace.c
May 7, 2024
@ceolin FYI |
Hm... I will need a GCC 13/14 enabled Zephyr SDK to properly test any changes. |
dcpleung
added a commit
to dcpleung/zephyr
that referenced
this issue
May 15, 2024
The sys_bitfield_(clear/set)_bit() work on pointer size element. However, _thread_idx_map[] is a byte array. On little endian systems, the bitops should work fine. However, on big endian systems, changing the lower bits may actually be manipulating memory outside the array when CONFIG_MAX_THREAD_BYTES is not multiple of 4. So modify the code to perform bit ops on a per-byte basis. Fixes zephyrproject-rtos#72430 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
dcpleung
added a commit
to dcpleung/zephyr
that referenced
this issue
May 15, 2024
The sys_bitfield_(clear/set)_bit() work on pointer size element. However, _thread_idx_map[] is a byte array. On little endian systems, the bitops should work fine. However, on big endian systems, changing the lower bits may actually be manipulating memory outside the array when CONFIG_MAX_THREAD_BYTES is not multiple of 4. So modify the code to perform bit ops on a per-byte basis. Fixes zephyrproject-rtos#72430 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
jhedberg
pushed a commit
that referenced
this issue
May 18, 2024
The sys_bitfield_(clear/set)_bit() work on pointer size element. However, _thread_idx_map[] is a byte array. On little endian systems, the bitops should work fine. However, on big endian systems, changing the lower bits may actually be manipulating memory outside the array when CONFIG_MAX_THREAD_BYTES is not multiple of 4. So modify the code to perform bit ops on a per-byte basis. Fixes #72430 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: Kernel
area: Userspace
Userspace
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Describe the bug
GCC 13 has improved analysis which raises a warning due to reading address outside of
_thread_idx_map
.If
CONFIG_MAX_THREAD_BYTES
is not a multiple of 4 the cast touint32_t*
will read beyond array boundaries.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Build without warnings.
Logs and console output
The text was updated successfully, but these errors were encountered: