]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.7] bpo-27987: align PyGC_Head to alignof(long double) (GH-13335) (GH-13581)
authorInada Naoki <songofacandy@gmail.com>
Mon, 3 Jun 2019 01:51:32 +0000 (10:51 +0900)
committerGregory P. Smith <greg@krypto.org>
Mon, 3 Jun 2019 01:51:31 +0000 (18:51 -0700)
This reverts commit 2156fec1f7a8f9972e90cdbaf404e3fd9eaccb35.

Now that https://github.com/python/cpython/commit/1b85f4ec45a5d63188ee3866bd55eb29fdec7fbf is in, this change makes sense.

Include/objimpl.h
Misc/NEWS.d/next/Core and Builtins/2019-05-15-18-28-43.bpo-27987.FaxuLy.rst [new file with mode: 0644]

index 057bb50cbda9e22da6600807a7be091cc19f0fea..0436ba7899d9a8a3769ff4d228982439707254b0 100644 (file)
@@ -255,7 +255,11 @@ 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 */
+    // 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;
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 (file)
index 0000000..9807347
--- /dev/null
@@ -0,0 +1,2 @@
+``PyGC_Head`` structure is aligned to ``long double``.  This is needed to
+ensure GC-ed objects are aligned properly.  Patch by Inada Naoki.