Skip to content

Commit 8766cb7

Browse files
methanegpshead
authored andcommitted
[3.7] bpo-27987: align PyGC_Head to alignof(long double) (pythonGH-13335) (pythonGH-13581)
This reverts commit 2156fec. Now that python@1b85f4e is in, this change makes sense.
1 parent 9390e98 commit 8766cb7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Include/objimpl.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ typedef union _gc_head {
255255
union _gc_head *gc_prev;
256256
Py_ssize_t gc_refs;
257257
} gc;
258-
double dummy; /* force worst-case alignment */
258+
long double dummy; /* force worst-case alignment */
259+
// malloc returns memory block aligned for any built-in types and
260+
// long double is the largest standard C type.
261+
// On amd64 linux, long double requires 16 byte alignment.
262+
// See bpo-27987 for more discussion.
259263
} PyGC_Head;
260264

261265
extern PyGC_Head *_PyGC_generation0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
``PyGC_Head`` structure is aligned to ``long double``. This is needed to
2+
ensure GC-ed objects are aligned properly. Patch by Inada Naoki.

0 commit comments

Comments
 (0)