Pearu Peterson created ARROW-4825:
-------------------------------------
Summary: MemoryPool is destructed before deallocating its buffers
leads to segfault
Key: ARROW-4825
URL: https://issues.apache.org/jira/browse/ARROW-4825
Project: Apache Arrow
Issue Type: Bug
Components: Python
Affects Versions: 0.13.0
Reporter: Pearu Peterson
Consider the following test function:
```
def test_memory_pool():
import pyarrow as pa
pool = pa.logging_memory_pool(pa.default_memory_pool())
buf = pa.allocate_buffer(10, memory_pool=pool)
```
that will fail with segfault when `pool` is garbage collected before `buf`.
However, the following test function succeeds:
```
def test_memory_pool():
import pyarrow as pa
pool = pa.logging_memory_pool(pa.default_memory_pool())
buf = pa.allocate_buffer(10, memory_pool=pool)
del buf
```
because all buffers are freed before `pool` destruction.
To fix this issue, the pool instance should be attached to buffer instances
that the pool is creating. This will ensure that `pool` will be alive until all
its buffers are destroyed.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)