Commits


Steven Fackler authored and Andrew Lamb committed 3fa8f79c88a
ARROW-11488: [Rust] Don't leak memory in StructBuilder This PR fixes the following MIRI error (example from https://github.com/apache/arrow/pull/9373/checks?check_run_id=1830406627): ``` test array::builder::tests::test_string_dictionary_builder_with_reserved_null_value ... ok error: Undefined Behavior: trying to reborrow for SharedReadWrite at alloc9600855, but parent tag <26451274> does not have an appropriate item in the borrow stack --> arrow/src/array/builder.rs:1434:9 | 1434 | self.field_anys[i].downcast_mut::<T>() | ^^^^^^^^^^^^^^^^^^ trying to reborrow for SharedReadWrite at alloc9600855, but parent tag <26451274> does not have an appropriate item in the borrow stack | = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information = note: inside `array::builder::StructBuilder::field_builder::<array::builder::GenericStringBuilder<i32>>` at arrow/src/array/builder.rs:1434:9 note: inside `array::builder::tests::test_struct_array_builder` at arrow/src/array/builder.rs:2824:30 --> arrow/src/array/builder.rs:2824:30 | 2824 | let string_builder = builder | ______________________________^ 2825 | | .field_builder::<StringBuilder>(0) | |______________________________________________^ note: inside closure at arrow/src/array/builder.rs:2810:5 --> arrow/src/array/builder.rs:2810:5 | 2810 | / fn test_struct_array_builder() { 2811 | | let string_builder = StringBuilder::new(4); 2812 | | let int_builder = Int32Builder::new(4); 2813 | | ... | 2889 | | } 2890 | | } | |_____^ = note: inside `<[closure@arrow/src/array/builder.rs:2810:5: 2890:6] as ``` Closes #9409 from sfackler/struct-memory-leak Authored-by: Steven Fackler <sfackler@palantir.com> Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>