Author fweimer
Recipients fweimer, gregory.p.smith, pablogsal, vstinner
Date 2019-04-15.11:02:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555326164.29.0.148220134775.issue36618@roundup.psfhosted.org>
In-reply-to
Content
The issue is related to the definition of PyCArgObject:

typedef struct tagPyCArgObject PyCArgObject;

struct tagPyCArgObject {
    PyObject_HEAD
    ffi_type *pffi_type;
    char tag;
    union {
        char c;
        char b;
        short h;
        int i;
        long l;
        long long q;
        long double D;
        double d;
        float f;
        void *p;
    } value;
    PyObject *obj;
    Py_ssize_t size; /* for the 'V' tag */
};

This object must be allocated with suitable alignment (which is 16 on many platforms), and the default Python allocator apparently provides 8-byte alignment only on 64-bit platforms.  In short, using PyObject_New with PyCArgObject results in undefined behavior.

This issue potentially affects all compilers, not just Clang.
History
Date User Action Args
2019-04-15 11:02:44fweimersetrecipients: + fweimer, gregory.p.smith, vstinner, pablogsal
2019-04-15 11:02:44fweimersetmessageid: <1555326164.29.0.148220134775.issue36618@roundup.psfhosted.org>
2019-04-15 11:02:44fweimerlinkissue36618 messages
2019-04-15 11:02:44fweimercreate