[
https://issues.apache.org/jira/browse/ARROW-11488?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Steven Fackler updated ARROW-11488:
-----------------------------------
Description:
The StructBuilder stores two copies of the inner ArrayBuilders in two separate
Vecs via some unsafe code. To avoid double-dropping the builders, the
StructBuilder Drop impl uses mem::forget on one of the vectors. This avoids
calling the destructor of the ArrayBuilders twice, but also leaks the memory of
the Vec itself.
In addition, the double-vecs with the unsafe code is completely unnecessary
since you can just call `ArrayBuilder::as_mut_any` on the `dyn ArrayBuilder`
instead of having to covert to a `Box<dyn Any>`.
was:
The StructBuilder stores two copies of the inner ArrayBuilders in two separate
Vecs via some unsafe code. To avoid double-dropping the builders, the
StructBuilder Drop impl uses mem::forget on one of the vectors. This avoids
calling the destructor of the ArrayBuilders twice, but also leaks the memory of
the Vec itself.
In addition, the double-vecs with the unsafe code is completely unnecessary
since you can just call `ArrayBuilder::as_mut_any` on the `dyn ArrayBuilder`
instead of having to covert to a `dyn Any`.
> [Rust]: StructBuilder's Drop impl leaks memory
> ----------------------------------------------
>
> Key: ARROW-11488
> URL: https://issues.apache.org/jira/browse/ARROW-11488
> Project: Apache Arrow
> Issue Type: Bug
> Components: Rust
> Affects Versions: 3.0.0
> Reporter: Steven Fackler
> Priority: Major
>
> The StructBuilder stores two copies of the inner ArrayBuilders in two
> separate Vecs via some unsafe code. To avoid double-dropping the builders,
> the StructBuilder Drop impl uses mem::forget on one of the vectors. This
> avoids calling the destructor of the ArrayBuilders twice, but also leaks the
> memory of the Vec itself.
> In addition, the double-vecs with the unsafe code is completely unnecessary
> since you can just call `ArrayBuilder::as_mut_any` on the `dyn ArrayBuilder`
> instead of having to covert to a `Box<dyn Any>`.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)