Skip to content

Commit 4b77b68

Browse files
committed
Fix: unaligned pointer caused crashes
1 parent 0f2094b commit 4b77b68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graalpython/com.oracle.graal.python.cext/include/internal/pycore_object.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,12 @@ _PyObject_IS_GC(PyObject *obj)
367367
static inline size_t
368368
_PyType_PreHeaderSize(PyTypeObject *tp)
369369
{
370-
// GraalPy change: we put only one pointer for dict, we don't store it inlined [GR-61996]
370+
/* Note: the pre-header size must have a 16-byte alignment. This is
371+
necessary for higher optimization levels which assume the alignment
372+
(inferred from the struct size) and emit instructions that require
373+
this alignment. */
371374
return _PyType_IS_GC(tp) * sizeof(PyGC_Head) +
372-
_PyType_HasFeature(tp, Py_TPFLAGS_PREHEADER) * /* 2 * */ sizeof(PyObject *);
375+
_PyType_HasFeature(tp, Py_TPFLAGS_PREHEADER) * 2 * sizeof(PyObject *);
373376
}
374377

375378
void _PyObject_GC_Link(PyObject *op);

0 commit comments

Comments
 (0)