Martin Panter added the comment:

I traced this down to part of revision 1da9630e9b7f (Issue #22896). If I revert 
the changes to CDataType_from_buffer() at 
<https://hg.python.org/cpython/rev/1da9630e9b7f/#l4.3>, the crash no longer 
happens. I suspect the offending code is this, that is trying to stash the 
original buffer protocol supporting object into a memory view:

mv = PyMemoryView_FromBuffer(&buffer);
if (mv == NULL) {
    PyBuffer_Release(&buffer);
    return NULL;
}
/* Hack the memoryview so that it will release the buffer. */
((PyMemoryViewObject *)mv)->mbuf->master.obj = buffer.obj;
((PyMemoryViewObject *)mv)->view.obj = buffer.obj;
//~ Py_INCREF(buffer.obj);
if (-1 == KeepRef((CDataObject *)result, -1, mv))
    result = NULL;

If I enable my INCREF() line it also stops the crash, but I guess at the 
expense of a memory leak.

----------
components: +ctypes -Interpreter Core
keywords: +3.4regression
nosy: +serhiy.storchaka

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

Reply via email to