Skip to content
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

BUG: Fix -fsanitize=alignment issue in numpy/_core/src/multiarray/arraytypes.c.src #25202

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

charris
Copy link
Member

@charris charris commented Nov 20, 2023

Backport of #25136.

OBJECT_nonzero may be called with misaligned pointers, manifesting as a -fsanitize=alignment failure. This is UB per C11 6.3.2.3

A pointer to an object type may be converted to a pointer to a different object type. If the resulting pointer is not correctly aligned) for the referenced type, the behavior is undefined.

Nevertheless, Clang only checks alignment when the unaligned pointer is accessed. https://lists.llvm.org/pipermail/llvm-dev/2016-January/094012.html Call memcpy with unaligned arguments instead to work with new Clang (llvm/llvm-project#67766).

…es.c.src

OBJECT_nonzero may be called with misaligned pointers, manifesting as a
-fsanitize=alignment failure. This is UB per C11 6.3.2.3

> A pointer to an object type may be converted to a pointer to a different object type. If the resulting pointer is not correctly aligned) for the referenced type, the behavior is undefined.

Nevertheless, Clang only checks alignment when the unaligned pointer is accessed.
https://lists.llvm.org/pipermail/llvm-dev/2016-January/094012.html
Call memcpy with unaligned arguments instead to work with new Clang
(llvm/llvm-project#67766).
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Nov 20, 2023
@charris charris added this to the 1.26.3 release milestone Nov 20, 2023
@charris charris merged commit dfa7e0d into numpy:maintenance/1.26.x Nov 20, 2023
59 of 61 checks passed
@charris charris deleted the backport-25136 branch November 20, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants