Skip to content

Help understanding MIRI failure in FFI boundaries. #1800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorgecarleitao opened this issue May 15, 2021 · 7 comments
Closed

Help understanding MIRI failure in FFI boundaries. #1800

jorgecarleitao opened this issue May 15, 2021 · 7 comments
Labels
A-aliasing Area: This affects the aliasing model (Stacked/Tree Borrows) C-support Category: Not necessarily a bug, but someone asking for support

Comments

@jorgecarleitao
Copy link

jorgecarleitao commented May 15, 2021

At arrow2, we have an FFI to interact with other languages, and are observing a failure in a single check while performing a roundtrip across FFI boundaries (i.e. Rust is both the producer and consumer), and we are uncertain what the exact problem is.

git clone git@github.com:jorgecarleitao/arrow2.git
cd arrow2
cargo miri test --lib --no-default-features ffi::array::tests::test_binary

The message is

test ffi::array::tests::test_binary ... error: Undefined Behavior: trying to reborrow for SharedReadOnly at alloc739545, but parent tag <1887658> does not have an appropriate item in the borrow stack
   --> /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/unique.rs:118:18
    |
118 |         unsafe { &*self.as_ptr() }
    |                  ^^^^^^^^^^^^^^^ trying to reborrow for SharedReadOnly at alloc739545, but parent tag <1887658> 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

I was wondering if anyone knows whether this is a true positive and why. It is not entirely clear to me what the .md file means, and would appreciate any tips wrt to this.

I am sorry I am unable to offer a simple example, but the problem itself is non-trivial as it emerges during a non-trivial release callback mechanism, and we do not observe it in all types (e.g. the test ffi::array::tests::test_u32 passes).

To reproduce on the CI, clone it in github and comment this line .

@RalfJung
Copy link
Member

RalfJung commented May 15, 2021

Yeah, Stacked Borrows errors can be hard to debug...

The first step is to reproduce the error without -Zmiri-disable-isolation, which it seems you already did. Great!
The next step is to use -Zmiri-track-pointer-tag=<tag> -- in your case, -Zmiri-track-pointer-tag=1887658. That should tell you when the tag is being removed from this location. (There also is the possibility that the tag was never added to this location in the first place.)

Btw, to paste console output into a GitHub issue, use a code block -- these are marked with ``` at the beginning and end (these markers must be on their own lines).

@jorgecarleitao
Copy link
Author

jorgecarleitao commented May 15, 2021

Thanks a lot for the quick reply, @RalfJung

So, the flow of this tag goes as follows:

  1. we create a buffers_ptr = Box<[*const std::os::raw::c_void]> when exporting to FFI on a private struct to keep references when the release callback is called.
  2. We expose these pointers to the (public) FFI via buffers = buffers_ptr.as_mut_ptr()
  3. when importing, we pop them using *buffers.add(index) (assumes a FFI contract). This is done twice in the failing test, for two different indexes.
  4. at the end of the stack of the test, we release everything

On the test that passes, the step 3. is only done once. This seems to be the complain, that are poping a unique twice.

What I do not understand is why this is a concern: we are just defering the pointer of pointers to read different positions; we do not actually store that pointer anywhere when reading it.

Maybe another way of asking this: what is a Stacked Borrows error? ^_^

@RalfJung
Copy link
Member

Maybe another way of asking this: what is a Stacked Borrows error? ^_^

Stacked Borrows is a candidate for the Rust aliasing model. A Stacked Borrows error means your code (or code you called) does something which is in contradiction with those aliasing rules.

Could you show the output with "track-pointer-tag"?

@jorgecarleitao
Copy link
Author

jorgecarleitao commented May 15, 2021

Thanks for the explanation. Sorry for the wall of text below:

EDIT: see below

@jorgecarleitao
Copy link
Author

jorgecarleitao commented May 15, 2021

Sorry for the noise; that was a wrong tag; I changed some unrelated code, which changed the tag number; correct below:

running 1 test
test ffi::array::tests::test_binary ... note: tracking was triggered
   --> src/ffi/ffi.rs:357:17
    |
357 |                 buffers_ptr,
    |                 ^^^^^^^^^^^ created tag 1900036
    |
    = note: inside `ffi::ffi::Ffi_ArrowArray::new` at src/ffi/ffi.rs:357:17
note: inside `ffi::ffi::export_to_c` at src/ffi/ffi.rs:666:25
   --> src/ffi/ffi.rs:666:25
    |
666 |         array: Arc::new(Ffi_ArrowArray::new(array)),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_round_trip::<array::binary::BinaryArray<i32>>` at src/ffi/array.rs:102:30
   --> src/ffi/array.rs:102:30
    |
102 |         let array = Arc::new(ffi::export_to_c(b)?);
    |                              ^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_binary` at src/ffi/array.rs:146:9
   --> src/ffi/array.rs:146:9
    |
146 |         test_round_trip(data)
    |         ^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/ffi/array.rs:143:5
   --> src/ffi/array.rs:143:5
    |
143 | /     fn test_binary() -> Result<()> {
144 | |         let data =
145 | |             BinaryArray::<i32>::from(&vec![Some(b"a".as_ref()), None, Some(b"bb".as_ref()), None]);
146 | |         test_round_trip(data)
147 | |     }
    | |_____^
    = note: inside `<[closure@src/ffi/array.rs:143:5: 147:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:567:5
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:558:30
    = note: inside `<[closure@test::run_test::{closure#2}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1546:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `test::run_test_in_process` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:589:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:486:39
    = note: inside `test::run_test::run_test_inner` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:522:13
    = note: inside `test::run_test` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:555:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:301:13
    = note: inside `test::run_tests_console` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/console.rs:289:5
    = note: inside `test::test_main` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:122:15
    = note: inside `test::test_main_static` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:141:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `std::rt::lang_start_internal` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:51:25
    = note: inside `std::rt::lang_start::<()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
    = note: this note originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

note: tracking was triggered
   --> src/ffi/ffi.rs:447:15
    |
447 |     let ptr = *buffers.add(index);
    |               ^^^^^^^^^^^^^^^^^^^ popped tracked tag for item [Unique for <1900036>]
    |
    = note: inside `ffi::ffi::create_bitmap` at src/ffi/ffi.rs:447:15
note: inside `<std::sync::Arc<ffi::ffi::ArrowArray> as ffi::ffi::ArrowArrayRef>::validity` at src/ffi/ffi.rs:538:13
   --> src/ffi/ffi.rs:538:13
    |
538 |             create_bitmap(self.array(), self.deallocation(), 0).map(Some)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `array::binary::ffi::<impl array::ffi::FromFfi<std::sync::Arc<ffi::ffi::ArrowArray>> for array::binary::BinaryArray<i32>>::try_from_ffi` at src/array/binary/ffi.rs:44:37
   --> src/array/binary/ffi.rs:44:37
    |
44  |         let mut validity = unsafe { array.validity() }?;
    |                                     ^^^^^^^^^^^^^^^^
note: inside `ffi::array::try_from::<std::sync::Arc<ffi::ffi::ArrowArray>>` at src/ffi/array.rs:64:38
   --> src/ffi/array.rs:64:38
    |
64  |         DataType::Binary => Box::new(BinaryArray::<i32>::try_from_ffi(array)?),
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_round_trip::<array::binary::BinaryArray<i32>>` at src/ffi/array.rs:106:22
   --> src/ffi/array.rs:106:22
    |
106 |         let result = try_from(array)?;
    |                      ^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_binary` at src/ffi/array.rs:146:9
   --> src/ffi/array.rs:146:9
    |
146 |         test_round_trip(data)
    |         ^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/ffi/array.rs:143:5
   --> src/ffi/array.rs:143:5
    |
143 | /     fn test_binary() -> Result<()> {
144 | |         let data =
145 | |             BinaryArray::<i32>::from(&vec![Some(b"a".as_ref()), None, Some(b"bb".as_ref()), None]);
146 | |         test_round_trip(data)
147 | |     }
    | |_____^
    = note: inside `<[closure@src/ffi/array.rs:143:5: 147:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:567:5
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:558:30
    = note: inside `<[closure@test::run_test::{closure#2}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1546:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `test::run_test_in_process` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:589:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:486:39
    = note: inside `test::run_test::run_test_inner` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:522:13
    = note: inside `test::run_test` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:555:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:301:13
    = note: inside `test::run_tests_console` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/console.rs:289:5
    = note: inside `test::test_main` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:122:15
    = note: inside `test::test_main_static` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:141:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `std::rt::lang_start_internal` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:51:25
    = note: inside `std::rt::lang_start::<()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
    = note: this note originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

note: tracking was triggered
   --> src/ffi/ffi.rs:418:15
    |
418 |     let ptr = *buffers.add(index);
    |               ^^^^^^^^^^^^^^^^^^^ popped tracked tag for item [Unique for <1900036>]
    |
    = note: inside `ffi::ffi::create_buffer::<i32>` at src/ffi/ffi.rs:418:15
note: inside `<std::sync::Arc<ffi::ffi::ArrowArray> as ffi::ffi::ArrowArrayRef>::buffer::<i32>` at src/ffi/ffi.rs:547:9
   --> src/ffi/ffi.rs:547:9
    |
547 | /         create_buffer::<T>(
548 | |             self.array(),
549 | |             &self.data_type()?,
550 | |             self.deallocation(),
551 | |             index + 1,
552 | |         )
    | |_________^
note: inside `array::binary::ffi::<impl array::ffi::FromFfi<std::sync::Arc<ffi::ffi::ArrowArray>> for array::binary::BinaryArray<i32>>::try_from_ffi` at src/array/binary/ffi.rs:45:36
   --> src/array/binary/ffi.rs:45:36
    |
45  |         let mut offsets = unsafe { array.buffer::<O>(0) }?;
    |                                    ^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::try_from::<std::sync::Arc<ffi::ffi::ArrowArray>>` at src/ffi/array.rs:64:38
   --> src/ffi/array.rs:64:38
    |
64  |         DataType::Binary => Box::new(BinaryArray::<i32>::try_from_ffi(array)?),
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_round_trip::<array::binary::BinaryArray<i32>>` at src/ffi/array.rs:106:22
   --> src/ffi/array.rs:106:22
    |
106 |         let result = try_from(array)?;
    |                      ^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_binary` at src/ffi/array.rs:146:9
   --> src/ffi/array.rs:146:9
    |
146 |         test_round_trip(data)
    |         ^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/ffi/array.rs:143:5
   --> src/ffi/array.rs:143:5
    |
143 | /     fn test_binary() -> Result<()> {
144 | |         let data =
145 | |             BinaryArray::<i32>::from(&vec![Some(b"a".as_ref()), None, Some(b"bb".as_ref()), None]);
146 | |         test_round_trip(data)
147 | |     }
    | |_____^
    = note: inside `<[closure@src/ffi/array.rs:143:5: 147:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:567:5
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:558:30
    = note: inside `<[closure@test::run_test::{closure#2}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1546:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `test::run_test_in_process` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:589:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:486:39
    = note: inside `test::run_test::run_test_inner` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:522:13
    = note: inside `test::run_test` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:555:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:301:13
    = note: inside `test::run_tests_console` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/console.rs:289:5
    = note: inside `test::test_main` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:122:15
    = note: inside `test::test_main_static` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:141:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `std::rt::lang_start_internal` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:51:25
    = note: inside `std::rt::lang_start::<()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
    = note: this note originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

note: tracking was triggered
   --> src/ffi/ffi.rs:418:15
    |
418 |     let ptr = *buffers.add(index);
    |               ^^^^^^^^^^^^^^^^^^^ popped tracked tag for item [Unique for <1900036>]
    |
    = note: inside `ffi::ffi::create_buffer::<u8>` at src/ffi/ffi.rs:418:15
note: inside `<std::sync::Arc<ffi::ffi::ArrowArray> as ffi::ffi::ArrowArrayRef>::buffer::<u8>` at src/ffi/ffi.rs:547:9
   --> src/ffi/ffi.rs:547:9
    |
547 | /         create_buffer::<T>(
548 | |             self.array(),
549 | |             &self.data_type()?,
550 | |             self.deallocation(),
551 | |             index + 1,
552 | |         )
    | |_________^
note: inside `array::binary::ffi::<impl array::ffi::FromFfi<std::sync::Arc<ffi::ffi::ArrowArray>> for array::binary::BinaryArray<i32>>::try_from_ffi` at src/array/binary/ffi.rs:46:31
   --> src/array/binary/ffi.rs:46:31
    |
46  |         let values = unsafe { array.buffer::<u8>(1) }?;
    |                               ^^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::try_from::<std::sync::Arc<ffi::ffi::ArrowArray>>` at src/ffi/array.rs:64:38
   --> src/ffi/array.rs:64:38
    |
64  |         DataType::Binary => Box::new(BinaryArray::<i32>::try_from_ffi(array)?),
    |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_round_trip::<array::binary::BinaryArray<i32>>` at src/ffi/array.rs:106:22
   --> src/ffi/array.rs:106:22
    |
106 |         let result = try_from(array)?;
    |                      ^^^^^^^^^^^^^^^
note: inside `ffi::array::tests::test_binary` at src/ffi/array.rs:146:9
   --> src/ffi/array.rs:146:9
    |
146 |         test_round_trip(data)
    |         ^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/ffi/array.rs:143:5
   --> src/ffi/array.rs:143:5
    |
143 | /     fn test_binary() -> Result<()> {
144 | |         let data =
145 | |             BinaryArray::<i32>::from(&vec![Some(b"a".as_ref()), None, Some(b"bb".as_ref()), None]);
146 | |         test_round_trip(data)
147 | |     }
    | |_____^
    = note: inside `<[closure@src/ffi/array.rs:143:5: 147:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:567:5
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:558:30
    = note: inside `<[closure@test::run_test::{closure#2}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1546:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `test::run_test_in_process` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:589:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:486:39
    = note: inside `test::run_test::run_test_inner` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:522:13
    = note: inside `test::run_test` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:555:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:301:13
    = note: inside `test::run_tests_console` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/console.rs:289:5
    = note: inside `test::test_main` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:122:15
    = note: inside `test::test_main_static` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:141:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `std::rt::lang_start_internal` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:51:25
    = note: inside `std::rt::lang_start::<()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
    = note: this note originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: Undefined Behavior: trying to reborrow for SharedReadOnly at alloc744378, but parent tag <1900036> does not have an appropriate item in the borrow stack
   --> /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/unique.rs:118:18
    |
118 |         unsafe { &*self.as_ptr() }
    |                  ^^^^^^^^^^^^^^^ trying to reborrow for SharedReadOnly at alloc744378, but parent tag <1900036> 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 `std::ptr::Unique::<[*const std::ffi::c_void]>::as_ref` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/unique.rs:118:18
    = note: inside `alloc::alloc::box_free::<[*const std::ffi::c_void], std::alloc::Global>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:331:32
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<[*const std::ffi::c_void]>> - shim(Some(std::boxed::Box<[*const std::ffi::c_void]>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<ffi::ffi::PrivateData> - shim(Some(ffi::ffi::PrivateData))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<ffi::ffi::PrivateData>> - shim(Some(std::boxed::Box<ffi::ffi::PrivateData>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
note: inside `ffi::ffi::c_release_array` at src/ffi/ffi.rs:310:1
   --> src/ffi/ffi.rs:310:1
    |
310 | }
    | ^
note: inside `<ffi::ffi::Ffi_ArrowArray as std::ops::Drop>::drop` at src/ffi/ffi.rs:291:39
   --> src/ffi/ffi.rs:291:39
    |
291 |             Some(release) => unsafe { release(self) },
    |                                       ^^^^^^^^^^^^^
    = note: inside `std::ptr::drop_in_place::<ffi::ffi::Ffi_ArrowArray> - shim(Some(ffi::ffi::Ffi_ArrowArray))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::sync::Arc::<ffi::ffi::Ffi_ArrowArray>::drop_slow` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1039:18
    = note: inside `<std::sync::Arc<ffi::ffi::Ffi_ArrowArray> as std::ops::Drop>::drop` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1571:13
    = note: inside `std::ptr::drop_in_place::<std::sync::Arc<ffi::ffi::Ffi_ArrowArray>> - shim(Some(std::sync::Arc<ffi::ffi::Ffi_ArrowArray>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<ffi::ffi::ArrowArray> - shim(Some(ffi::ffi::ArrowArray))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::sync::Arc::<ffi::ffi::ArrowArray>::drop_slow` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1039:18
    = note: inside `<std::sync::Arc<ffi::ffi::ArrowArray> as std::ops::Drop>::drop` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1571:13
    = note: inside `std::ptr::drop_in_place::<std::sync::Arc<ffi::ffi::ArrowArray>> - shim(Some(std::sync::Arc<ffi::ffi::ArrowArray>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<buffer::bytes::Deallocation> - shim(Some(buffer::bytes::Deallocation))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<buffer::bytes::Bytes<u8>> - shim(Some(buffer::bytes::Bytes<u8>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::sync::Arc::<buffer::bytes::Bytes<u8>>::drop_slow` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1039:18
    = note: inside `<std::sync::Arc<buffer::bytes::Bytes<u8>> as std::ops::Drop>::drop` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:1571:13
    = note: inside `std::ptr::drop_in_place::<std::sync::Arc<buffer::bytes::Bytes<u8>>> - shim(Some(std::sync::Arc<buffer::bytes::Bytes<u8>>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<bitmap::immutable::Bitmap> - shim(Some(bitmap::immutable::Bitmap))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<std::option::Option<bitmap::immutable::Bitmap>> - shim(Some(std::option::Option<bitmap::immutable::Bitmap>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<array::binary::BinaryArray<i32>> - shim(Some(array::binary::BinaryArray<i32>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<dyn array::Array>> - shim(Some(std::boxed::Box<dyn array::Array>))` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:187:1
note: inside `ffi::array::tests::test_round_trip::<array::binary::BinaryArray<i32>>` at src/ffi/array.rs:110:5
   --> src/ffi/array.rs:110:5
    |
110 |     }
    |     ^
note: inside `ffi::array::tests::test_binary` at src/ffi/array.rs:146:9
   --> src/ffi/array.rs:146:9
    |
146 |         test_round_trip(data)
    |         ^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/ffi/array.rs:143:5
   --> src/ffi/array.rs:143:5
    |
143 | /     fn test_binary() -> Result<()> {
144 | |         let data =
145 | |             BinaryArray::<i32>::from(&vec![Some(b"a".as_ref()), None, Some(b"bb".as_ref()), None]);
146 | |         test_round_trip(data)
147 | |     }
    | |_____^
    = note: inside `<[closure@src/ffi/array.rs:143:5: 147:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:567:5
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:558:30
    = note: inside `<[closure@test::run_test::{closure#2}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1546:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `test::run_test_in_process` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:589:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:486:39
    = note: inside `test::run_test::run_test_inner` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:522:13
    = note: inside `test::run_test` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:555:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:301:13
    = note: inside `test::run_tests_console` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/console.rs:289:5
    = note: inside `test::test_main` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:122:15
    = note: inside `test::test_main_static` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:141:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125:18
    = note: inside closure at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
    = note: inside `std::rt::lang_start_internal` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:51:25
    = note: inside `std::rt::lang_start::<()>` at /home/azureuser/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65:5
    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error; 2 warnings emitted

error: test failed, to rerun pass '--lib'

@RalfJung
Copy link
Member

RalfJung commented May 16, 2021

The first suspicious aspect of this code that I noticed is here
https://github.com/jorgecarleitao/arrow2/blob/7cc70cced0be799cc846335f560bef66ebd76a19/src/ffi/ffi.rs#L335
combined with
https://github.com/jorgecarleitao/arrow2/blob/7cc70cced0be799cc846335f560bef66ebd76a19/src/ffi/ffi.rs#L357

The first line creates a raw pointer into the Box<[_]>, but then the second line uses the original Box again. Box pointers must be unique, but now you have aliasing between a raw pointer and the Box stored in the PrivateData.

I assume what happens is that subsequently, you are using both the raw pointer and the Box to access the same data, and that is indeed an aliasing violation. When you want to have aliasing pointers like this, all aliases must be raw pointers.

@RalfJung RalfJung added A-aliasing Area: This affects the aliasing model (Stacked/Tree Borrows) C-support Category: Not necessarily a bug, but someone asking for support labels Dec 16, 2021
@RalfJung
Copy link
Member

I hope the question has been answered at least to some extend, so I will close the issue. Feel free to reopen if that is premature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-aliasing Area: This affects the aliasing model (Stacked/Tree Borrows) C-support Category: Not necessarily a bug, but someone asking for support
Projects
None yet
Development

No branches or pull requests

2 participants