[New-bugs-announce] [issue47179] pymalloc should align to max_align_t
Petr Viktorin
report at bugs.python.org
Thu Mar 31 04:59:44 EDT 2022
New submission from Petr Viktorin <encukou at gmail.com>:
malloc() returns memory that's "suitably aligned for any built-in type".
All of Python's allocation functions should do the same.
In bpo-27987 (PR-12850, PR-13336), the alignment was raised* to 16 bytes and `long double`. This is OK for current architectures, so there is no practical issue right now.
But, C11 defines a [max_align_t] type which sounds like the *correct* thing to use for determining pymalloc/PyGC_Head alignment.
At least we should assert that obmalloc's ALIGNMENT is a multiple of `alignof(max_align_t)`, and use max_align_t rather than `long double` in PyGC_Head.
See also this python-cffi issue: https://foss.heptapod.net/pypy/cffi/-/issues/531#note_181779
[max_align_t]: https://en.cppreference.com/w/c/types/max_align_t
* (on 64-bit arches)
----------
components: C API
messages: 416421
nosy: methane, petr.viktorin, pitrou, vstinner
priority: normal
severity: normal
status: open
title: pymalloc should align to max_align_t
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47179>
_______________________________________
More information about the New-bugs-announce
mailing list