[issue27987] obmalloc's 8-byte alignment causes undefined behavior
STINNER Victor
report at bugs.python.org
Tue May 21 20:09:17 EDT 2019
STINNER Victor <vstinner at redhat.com> added the comment:
> It seems to me that we don't need to have the PyObject structure containing a Python float to be 16-byte aligned. If so, could we introduce a new obmalloc API that returns memory with 8-byte alignment, for use by objects that know they don't require 16-byte alignment? floatobject.c could use this API to avoid the 33% overhead.
PyMem_Malloc / PyObject_Malloc only have one parameter: "size". It knows nothing about the allocated structure.
bpo-18835 discussed the idea of adding a new API which accept an alignment parameter. The issue was closed because of the lack of concrete usage.
In the clang crash bpo-36618 (which decided us to fix this issue), C alignof() function was discussed:
https://bugs.python.org/issue36618#msg340279
Copy of serge-sans-paille's comment:
"@vstinner: once you have a portable version of alignof, you can deciding to *not* use the pool allocator if the required alignment is greater than 8B, or you could modify the pool allocator to take alignment information as an extra parameter?"
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27987>
_______________________________________
More information about the Python-bugs-list
mailing list