vortex icon indicating copy to clipboard operation
vortex copied to clipboard

Run tests with MIRI for crates that don't use FFI

Open lwwmanning opened this issue 1 year ago • 1 comments

E.g., cargo +nightly miri test -p vortex-array

Won't work for enc-alp or any other crate that makes function calls via FFI, but still worth verifying the "core" module(s)

lwwmanning avatar Feb 26 '24 18:02 lwwmanning

MIRI currently fails:

test array::varbinview::test::flatten_array ... error: Undefined Behavior: incorrect layout on deallocation: alloc2920226 has size 32 and alignment 8, but gave size 32 and alignment 1
   --> /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/alloc.rs:119:14
    |
119 |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: alloc2920226 has size 32 and alignment 8, but gave size 32 and alignment 1
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE on thread `array::varbinview::test::flatten_array`:
    = note: inside `std::alloc::dealloc` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/alloc.rs:119:14: 119:64
    = note: inside `<arrow_buffer::bytes::Bytes as std::ops::Drop>::drop` at /Users/will/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arrow-buffer-52.1.0/src/bytes.rs:116:31: 116:78
    = note: inside `std::ptr::drop_in_place::<arrow_buffer::bytes::Bytes> - shim(Some(arrow_buffer::bytes::Bytes))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::sync::Arc::<arrow_buffer::bytes::Bytes>::drop_slow` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:1837:18: 1837:67
    = note: inside `<std::sync::Arc<arrow_buffer::bytes::Bytes> as std::ops::Drop>::drop` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:2524:13: 2524:29
    = note: inside `std::ptr::drop_in_place::<std::sync::Arc<arrow_buffer::bytes::Bytes>> - shim(Some(std::sync::Arc<arrow_buffer::bytes::Bytes>))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<arrow_buffer::Buffer> - shim(Some(arrow_buffer::Buffer))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<vortex_buffer::Buffer> - shim(Some(vortex_buffer::Buffer))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<std::option::Option<vortex_buffer::Buffer>> - shim(Some(std::option::Option<vortex_buffer::Buffer>))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<data::ArrayData> - shim(Some(data::ArrayData))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<Array> - shim(Some(Array))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<[Array]> - shim(Some([Array]))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::sync::Arc::<[Array]>::drop_slow` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:1837:18: 1837:67
    = note: inside `<std::sync::Arc<[Array]> as std::ops::Drop>::drop` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:2524:13: 2524:29
    = note: inside `std::ptr::drop_in_place::<std::sync::Arc<[Array]>> - shim(Some(std::sync::Arc<[Array]>))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<data::ArrayData> - shim(Some(data::ArrayData))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<Array> - shim(Some(Array))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<typed::TypedArray<array::varbinview::VarBinView>> - shim(Some(typed::TypedArray<array::varbinview::VarBinView>))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
    = note: inside `std::ptr::drop_in_place::<array::varbinview::VarBinViewArray> - shim(Some(array::varbinview::VarBinViewArray))` at /Users/will/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:542:1: 542:56
note: inside `array::varbinview::as_arrow`
   --> vortex-array/src/array/varbinview/mod.rs:291:1
    |
291 | }

lwwmanning avatar Jul 24 '24 19:07 lwwmanning

This is a real bug fwiw where we change the alignment between allocation and freeing. The solution is to either have our own buffer type with alignment #454 or support a 16 byte wide primitives so alignment doesn’t change

robert3005 avatar Jul 24 '24 19:07 robert3005

At one point I was investigating it and added some miri ignores to get more things to run https://github.com/spiraldb/vortex/pull/514

robert3005 avatar Jul 24 '24 19:07 robert3005