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

Copying inappropriately aligned buffer in ipc reader #2883

Merged
merged 10 commits into from
Oct 16, 2022
2 changes: 2 additions & 0 deletions arrow-array/src/array/list_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ mod tests {
assert_eq!(array.len(), 2);
assert_eq!(array.value(0), 0);
assert_eq!(array.value(1), 0);
assert_eq!(array.values(), &[0, 0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to call array.values() on the unaligned PrimitiveArray


// Not aligned.
// `ArrayData::build` checks buffer length.
Expand All @@ -889,6 +890,7 @@ mod tests {
let array = Int32Array::from(array_data);
assert_eq!(array.len(), 1);
assert_eq!(array.value(0), 0);
Copy link
Contributor

@tustvold tustvold Oct 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now UB, as this violates the safety requirement in PrimitiveArray::values.

I'm not sure why MIRI isn't catching this...

Edit: array.value doesn't call array.values so this test isn't UB. If you add a call to array.values() in this test, MIRI will fail

assert_eq!(array.values(), &[0]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


ArrayData::builder(DataType::Int32)
.add_buffer(buf2)
Expand Down