-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-104432: Use memcpy()
to avoid misaligned loads
#104433
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
Conversation
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Co-authored-by: Gregory P. Smith <greg@krypto.org>
I have made the requested changes; please review again |
Thanks for making the requested changes! @gpshead: please review the changes made to this pull request. |
memcpy()
to avoid misaligned loads
Thanks @chrstphrchvz for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
GH-107355 is a backport of this pull request to the 3.12 branch. |
GH-107356 is a backport of this pull request to the 3.11 branch. |
…04433) Fix potential unaligned memory access on C APIs involving returned sequences of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. (cherry picked from commit f01e4ce) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
…04433) Fix potential unaligned memory access on C APIs involving returned sequences of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. (cherry picked from commit f01e4ce) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
#107355) gh-104432: Use `memcpy()` to avoid misaligned loads (GH-104433) Fix potential unaligned memory access on C APIs involving returned sequences of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. (cherry picked from commit f01e4ce) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
@@ -0,0 +1,4 @@ | |||
Fix potential unaligned memory access on C APIs involving returned sequences | |||
of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These | |||
were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. Patch by |
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.
To clarify, I observed this on macOS for Intel. I have not confirmed if this also occurs on macOS for ARM, but I would not be surprised if it still does.
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.
Oops I shouldn't have bothered mentioning the architecture. no big deal though (feel free to make an edit PR if it bothers you).
I chose the word "revealed" in the wording as a way to indicate how it was found which is more interesting. I suspect the alignment sanitizer may flag this regardless of compilation target architecture but I didn't try to reproduce it myself. :)
I expect the fixup applies all over the place. Regardless of native transparent hardware support (x86) or triggering a trap to the OS to fix the unaligned access up (Alpha & a pile of very RISC thing) they are usually less efficient - so directly using code that detects it and does it right rather than triggering an even slower path is good.
#107356) gh-104432: Use `memcpy()` to avoid misaligned loads (GH-104433) Fix potential unaligned memory access on C APIs involving returned sequences of `char *` pointers within the :mod:`grp` and :mod:`socket` modules. These were revealed using a ``-fsaniziter=alignment`` build on ARM macOS. (cherry picked from commit f01e4ce) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
Fixes #104432.
gethost_common()
,mkgrent()
#104432