Skip to content

gh-144725: Relax over-strict alignment test on small arrays#145026

Open
jakelishman wants to merge 1 commit intopython:mainfrom
jakelishman:fix-array-alignment-test
Open

gh-144725: Relax over-strict alignment test on small arrays#145026
jakelishman wants to merge 1 commit intopython:mainfrom
jakelishman:fix-array-alignment-test

Conversation

@jakelishman
Copy link
Contributor

@jakelishman jakelishman commented Feb 19, 2026

This alignment test was introduced in gh-140557 with the intention of preventing empty-allocation optimisations from introducing odd-aligned pointers (as had previously been observed in such an optimisation for the empty bytearray, used in the Pickle v5 protocol). The test was over-specified, however, and compared to the maximum platform alignment, even though the requirements on allocators in general is only that the allocation is aligned for all data types that would in the requested allocation.

This test could fail on 32-bit platforms using mimalloc for single-byte array elements (e.g. 'B'), as the tiny allocation region only enforced 4-byte alignment, not the 8-byte maximum platform alignment of the double type.

This alignment test was introduced in pythongh-140557 with the intention of
preventing empty-allocation optimisations from introducing odd-aligned
pointers (as had previously been observed in such an optimisation for
the empty `bytearray`, used in the Pickle v5 protocol).  The test was
over-specified, however, and compared to the maximum platform alignment,
even though the requirements on allocators in general is only that the
allocation is aligned for all data types that would in the requested
allocation.

This test could fail on 32-bit platforms using `mimalloc` for
single-byte array elements (e.g. 'B'), as the tiny allocation region
only enforced 4-byte alignment, not the 8-byte maximum platform
alignment of the `double` type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments