This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients benjamin.peterson, fweimer, gregory.p.smith, methane, nascheme, pitrou, skrah, tgrigg, twouters, vstinner
Date 2019-04-15.10:17:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
PyGC_Head structure size depends on the Python version, sizes of 64-bit:

* 2.7: 32 bytes
* 3.6, 3.7: 24 bytes
* 3.8 (master): 16 bytes

bpo-36618 "clang expects memory aligned on 16 bytes, but pymalloc aligns to 8 bytes" should be even worse on 3.7: 24 is not aligned on 16. I don't understand why nobody saw this alignment issue previously. Maybe clang only became stricer about 16 bytes alignment recently?


typedef union _gc_head {
    struct {
        union _gc_head *gc_next;
        union _gc_head *gc_prev;
        Py_ssize_t gc_refs;
    } gc;
    double dummy; /* Force at least 8-byte alignment. */
    char dummy_padding[sizeof(union _gc_head_old)];
} PyGC_Head;


typedef union _gc_head {
    struct {
        union _gc_head *gc_next;
        union _gc_head *gc_prev;
        Py_ssize_t gc_refs;
    } gc;
    double dummy;  /* force worst-case alignment */
} PyGC_Head;


typedef struct {
    // Pointer to next object in the list.
    // 0 means the object is not tracked
    uintptr_t _gc_next;

    // Pointer to previous object in the list.
    // Lowest two bits are used for flags documented later.
    uintptr_t _gc_prev;
} PyGC_Head;

In 3.8, the union used to ensure alignment on a C double is gone.
Date User Action Args
2019-04-15 10:17:06vstinnersetrecipients: + vstinner, twouters, nascheme, gregory.p.smith, pitrou, benjamin.peterson, methane, skrah, fweimer, tgrigg
2019-04-15 10:17:06vstinnersetmessageid: <>
2019-04-15 10:17:06vstinnerlinkissue27987 messages
2019-04-15 10:17:06vstinnercreate