From 5397126a7d5a3dc52e75519281db9eba58ac72f1 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Tue, 14 Jun 2022 07:59:06 -0700 Subject: [PATCH 1/2] Fix leaks --- arrow/src/ffi.rs | 2 ++ arrow/src/ffi_stream.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs index 8eb28837ce5..84905af20a6 100644 --- a/arrow/src/ffi.rs +++ b/arrow/src/ffi.rs @@ -79,6 +79,8 @@ //! unsafe { //! Box::from_raw(out_array_ptr); //! Box::from_raw(out_schema_ptr); +//! Arc::from_raw(array_ptr); +//! Arc::from_raw(schema_ptr); //! } //! //! Ok(()) diff --git a/arrow/src/ffi_stream.rs b/arrow/src/ffi_stream.rs index bfc62b8888c..c06b5233344 100644 --- a/arrow/src/ffi_stream.rs +++ b/arrow/src/ffi_stream.rs @@ -500,6 +500,8 @@ mod tests { } assert_eq!(produced_batches, vec![batch.clone(), batch]); + + unsafe { Arc::from_raw(stream_ptr) }; Ok(()) } @@ -529,6 +531,8 @@ mod tests { } assert_eq!(produced_batches, vec![batch.clone(), batch]); + + unsafe { Arc::from_raw(stream_ptr) }; Ok(()) } From 89f3f83da6e6b3f44ee263d7f908af07ef2df4a0 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Tue, 14 Jun 2022 09:59:21 -0700 Subject: [PATCH 2/2] Fix leaks under array::ffi::tests --- arrow/src/array/ffi.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arrow/src/array/ffi.rs b/arrow/src/array/ffi.rs index 57329037bc4..12d6f440b78 100644 --- a/arrow/src/array/ffi.rs +++ b/arrow/src/array/ffi.rs @@ -74,6 +74,11 @@ mod tests { let result = &ArrayData::try_from(d1)?; assert_eq!(result, expected); + + unsafe { + Arc::from_raw(array); + Arc::from_raw(schema); + } Ok(()) }