-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Packed pointer warning in LL Controller #20724
Comments
This one does seem to be problematic: warning: converting a packed 'struct pdu_data' pointer (alignment 1) to a 'struct radio_le_conn_update_cmplt' pointer (alignment 2) may result in an unaligned pointer value [-Waddress-of-packed-member] Generally, Arm would throw an exception when trying to do unaligned access but in the case of a packed structure with pointers and such the compiler normally knows this and will use "relaxed" rules when generating code around these. The relaxed rules result in unaligned accesses being structured with multiple byte or word accesses (what ever is allowed). But if you are assigning a pointer of different types where one structure is packed and the other is not then the compiler won't know to use the relaxed rules and the differing alignments would cause additional problems... |
I have analyzed the implementation, the packed struct pdu_data is used as place holder of pointer to the message passed from controller's ISR contect to HCI thread context. The access to data by both the producing and consuming implementation is by use of unpacked structures. The current upstream implementation does not lead to any unaligned access in the unpacked structures. That said, I am not getting compile time warnings in my dev environ:
Is there something I need to do/add to build script to enable the reported warnings? |
@cvinayak, here's the full output against vanilla Zephyr master branch (6ba1fce). Compiler is
Building
|
@cvinayak |
@thomasstenersen could you give me the commandline and environment variables you have set so that I try to reproduce what you get. @joerchan see my earlier comment, I hardly use Zephyr SDK. I may be wrong, but attaching my ninja verbose for your perusal. I piped my GCC version and "ninja --verbose". |
@cvinayak Didn't see that comment. You are using arm-none-eabi-gcc from the ARCH package manager? It might not be the same build that you get from ARMs webpage. You shoud probably get that one instead. |
@cvinayak, no special environment.
Attached build.log @joerchan, I'm using the one built by Fedora. So not stock ARM build. Might be that the arch build does not enable |
@cvinayak @thomasstenersen AFAIK ARM maintains ARM support for GCC only on their website, not for different package managers. So I strongly recommend you switch to that one instead. |
I tested this both with Zephyr SDK 0.11.1:
And with GNU Arm Embedded 9-2019-q4, as downloaded from here:
Neither show any issues, and those are the officially supported toolchains for Arm. |
Describe the bug
GCC 9 throws new warnings for possible unaligned pointer issues. On some architectures this is not supported, or can be configured to not be supported. On ARM this would throw a Hard Fault Exception.
To Reproduce
Steps to reproduce the behavior:
Build BT Controller with GCC v9
Impact
This could end in HardFault or other forms of crash.
Screenshots or console output
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: