Skip to content

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

Merged
charris merged 1 commit into
numpy:maintenance/1.26.xfrom
charris:backport-25136
Nov 20, 2023
Merged

BUG: Fix -fsanitize=alignment issue in numpy/_core/src/multiarray/arraytypes.c.src#25202
charris merged 1 commit into
numpy:maintenance/1.26.xfrom
charris:backport-25136

Conversation

@charris
Copy link
Copy Markdown
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
@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.

2 participants