Skip to content
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

MIRI error in math_checked_divide_op/try_from_trusted_len_iter #1496

Closed
jhorstmann opened this issue Mar 28, 2022 · 0 comments · Fixed by #1497
Closed

MIRI error in math_checked_divide_op/try_from_trusted_len_iter #1496

jhorstmann opened this issue Mar 28, 2022 · 0 comments · Fixed by #1497
Labels
arrow Changes to the arrow crate bug

Comments

@jhorstmann
Copy link
Contributor

$ cargo +nightly miri test -- test_primitive_array_divide
    Finished test [unoptimized + debuginfo] target(s) in 0.07s
     Running unittests src/lib.rs (/home/user/Source/github/apache/arrow-rs/target/miri/x86_64-unknown-linux-gnu/debug/deps/arrow-af84b07dc5414fbf)

running 9 tests
test compute::kernels::arithmetic::tests::test_primitive_array_divide ... error: Undefined Behavior: pointer to alloc1677519 was dereferenced after this allocation got freed
    --> /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2103:14
     |
2103 |     unsafe { copy_nonoverlapping(src, dst, count) }
     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to alloc1677519 was dereferenced after this allocation got freed
     |
     = 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: inside `std::intrinsics::copy_nonoverlapping::<u8>` at /home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/intrinsics.rs:2103:14
note: inside `buffer::mutable::MutableBuffer::try_from_trusted_len_iter::<error::ArrowError, i32, std::iter::Map<std::iter::Zip<std::slice::Iter<i32>, std::slice::Iter<i32>>, [closure@arrow/src/compute/kernels/arithmetic.rs:145:18: 151:14]>>` at arrow/src/buffer/mutable.rs:543:13
    --> arrow/src/buffer/mutable.rs:543:13
     |
543  |             std::ptr::copy_nonoverlapping(src, dst, item_size);
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `buffer::immutable::Buffer::try_from_trusted_len_iter::<error::ArrowError, i32, std::iter::Map<std::iter::Zip<std::slice::Iter<i32>, std::slice::Iter<i32>>, [closure@arrow/src/compute/kernels/arithmetic.rs:145:18: 151:14]>>` at arrow/src/buffer/immutable.rs:294:12
    --> arrow/src/buffer/immutable.rs:294:12
     |
294  |         Ok(MutableBuffer::try_from_trusted_len_iter(iterator)?.into())
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `compute::kernels::arithmetic::math_checked_divide_op::<datatypes::types::Int32Type, [closure@arrow/src/compute/kernels/arithmetic.rs:568:48: 568:60]>` at arrow/src/compute/kernels/arithmetic.rs:153:18
    --> arrow/src/compute/kernels/arithmetic.rs:153:18
     |
153  |         unsafe { Buffer::try_from_trusted_len_iter(values) }
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `compute::kernels::arithmetic::divide::<datatypes::types::Int32Type>` at arrow/src/compute/kernels/arithmetic.rs:568:12
    --> arrow/src/compute/kernels/arithmetic.rs:568:12
     |
568  |     return math_checked_divide_op(left, right, |a, b| a / b);
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `compute::kernels::arithmetic::tests::test_primitive_array_divide` at arrow/src/compute/kernels/arithmetic.rs:756:17
    --> arrow/src/compute/kernels/arithmetic.rs:756:17
     |
756  |         let c = divide(&a, &b).unwrap();
     |                 ^^^^^^^^^^^^^^
note: inside closure at arrow/src/compute/kernels/arithmetic.rs:753:5
    --> arrow/src/compute/kernels/arithmetic.rs:753:5
     |
752  |       #[test]
     |       ------- in this procedural macro expansion
753  | /     fn test_primitive_array_divide() {
754  | |         let a = Int32Array::from(vec![15, 15, 8, 1, 9]);
755  | |         let b = Int32Array::from(vec![5, 6, 8, 9, 1]);
756  | |         let c = divide(&a, &b).unwrap();
...    |
761  | |         assert_eq!(9, c.value(4));
762  | |     }
     | |_____^
     = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants