[ 
https://issues.apache.org/jira/browse/ARROW-4825?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Pearu Peterson reassigned ARROW-4825:
-------------------------------------

    Assignee: Pearu Peterson

> [Python][C++] 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: C++, Python
>    Affects Versions: 0.13.0
>            Reporter: Pearu Peterson
>            Assignee: Pearu Peterson
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to