[issue7433] MemoryView memory_getbuf causes segfaults, double call to tp_releasebuffer
report at bugs.python.org
Fri Dec 4 15:24:51 CET 2009
Pauli Virtanen <pav at iki.fi> added the comment:
I think this is an implementation issue in MemoryView rather than an
issue with the buffer interface. PEP 3118 states, "This same bufferinfo
structure must be passed to bf_releasebuffer (if available) when the
consumer is done with the memory." -- this is not guaranteed by the
current MemoryView implementation.
The calls are not paired: the *_getbuf calls fill in structures with
data "view1", and "view2". The *_releasebuf calls receive structures
with data "view1", and "view1". The data filled in the second getbuf
call ("view2") is never passed back to *_releasebuf, as it is
overwritten with "view1" data by dup_buffer.
To work around this, *_releasebuf must be written so that it does not
use the "view" pointer passed to it -- the data structure may have been
shallow copied and any memory pointers in it may have already been freed.
I can try to cook up a patch fixing this.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list