From e3eea5fb4d3be12431ac496101cff60ddbf7969b Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 15 May 2019 18:25:23 +0900 Subject: [PATCH 1/3] bpo-27987: align sizeof(PyGC_Head) to alignof(long double) --- Include/objimpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/objimpl.h b/Include/objimpl.h index 057bb50cbda9e2..f828738b44fe91 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -255,7 +255,7 @@ typedef union _gc_head { union _gc_head *gc_prev; Py_ssize_t gc_refs; } gc; - double dummy; /* force worst-case alignment */ + long double dummy; /* force worst-case alignment (16 byte for amd64) */ } PyGC_Head; extern PyGC_Head *_PyGC_generation0; From 8c888666e3ca40acec5d4d967829c04bbf2d82fd Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Wed, 15 May 2019 18:28:46 +0900 Subject: [PATCH 2/3] add news entry --- .../Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst b/Misc/NEWS.d/next/Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst new file mode 100644 index 00000000000000..97ca37b262a1c4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst @@ -0,0 +1,2 @@ +``PyGC_Head`` structure is aligned to ``long double``. This is needed to +GC-ed objects are aligned properly. Patch by Inada Naoki. From 3c6affc983bb6d61e0d5b7142df68a20b59f5603 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Thu, 16 May 2019 20:59:42 +0900 Subject: [PATCH 3/3] more comment --- Include/objimpl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Include/objimpl.h b/Include/objimpl.h index f828738b44fe91..0436ba7899d9a8 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -255,7 +255,11 @@ typedef union _gc_head { union _gc_head *gc_prev; Py_ssize_t gc_refs; } gc; - long double dummy; /* force worst-case alignment (16 byte for amd64) */ + long double dummy; /* force worst-case alignment */ + // malloc returns memory block aligned for any built-in types and + // long double is the largest standard C type. + // On amd64 linux, long double requires 16 byte alignment. + // See bpo-27987 for more discussion. } PyGC_Head; extern PyGC_Head *_PyGC_generation0;