New submission from Dan Snider <mr.assume.a...@gmail.com>:

New to both C and the CPython api so I'm not sure what compiler details matter 
but this is with VS14 and default compile parameters on windows 10 with 32bit 
Python.

The following function:

static PyObject *spam(PyObject *module) {
    digit w = 9;
    int x = 9;
    long y = 9;
    int32_t z = 9;
    return Py_BuildValue("(HIK)(lll)(LLL)", w,w,w,x,y,z,x,y,z);  
}

returns:

>>> spam()
((9, 9, 38654705673), (9, 9, 9), (38654705673, 438244858264171835, 6133859984))

Above was the most I could fit in a single Py_BuildValue call without causing a 
crash (it instantly crashes if "O" or "N" fields are present). I believe this 
happens because the ints are being upcasted as pointers, which is undefined 
behavior.

----------
components: Interpreter Core, Windows
messages: 315300
nosy: bup, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Py_Build value is causing crashes with the "L" and "K" format characters 
when upcasting sub 64-bit integer types
type: crash
versions: Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33279>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to