[New-bugs-announce] [issue27987] obmalloc's 8-byte alignment causes undefined behavior
Benjamin Peterson
report at bugs.python.org
Tue Sep 6 20:17:10 EDT 2016
New submission from Benjamin Peterson:
ubsan complains about unaligned access when structs include "long double". An example error:
runtime error: member access within misaligned address 0x7f77dbba9798 for type 'struct CDataObject', which requires 16 byte alignment
This is because (on x86 anyway), long double is 16-bytes long and requires that alignment, but obmalloc only gives a 8-byte alignment. (glibc malloc() gives 16-byte alignment.)
I'm attaching a POC patch. I don't know what the impact of increasing the alignment is on obmalloc's performance or memory usage. It's also unfortunate that this patch increases the size of PyGC_Head to 32 bytes from 24 bytes. One can imagine a more middle-ground solution to this by allowing types to specify their required alignment.
----------
components: Interpreter Core
files: alignment.patch
keywords: patch
messages: 274688
nosy: benjamin.peterson
priority: normal
severity: normal
status: open
title: obmalloc's 8-byte alignment causes undefined behavior
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file44413/alignment.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27987>
_______________________________________
More information about the New-bugs-announce
mailing list