pycapnp icon indicating copy to clipboard operation
pycapnp copied to clipboard

`from_bytes` does not properly release memory buffers under mmap

Open poke1024 opened this issue 2 years ago • 0 comments

OS: macOS-12.1-arm64-arm-64bit Python: 3.9.7

Running the demo.py from the following minimal example

pycapnp-mmap-issue.zip

will reliably produce the following exception 100% of the time:

Traceback (most recent call last):
  File "/Users/ch/Desktop/pycapnp-mmap-issue/demo.py", line 18, in <module>
    mv.release()
BufferError: memoryview has 1 exported buffer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ch/Desktop/pycapnp-mmap-issue/demo.py", line 18, in <module>
    mv.release()
BufferError: cannot close exported pointers exist

I strongly suspect this will happen on other platforms as well. Note that the same issue appears when not creating an explicit memoryview (see read2() in attached code).

poke1024 avatar Jan 17 '22 10:01 poke1024