You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mbutrovich (via GitHub)" <gi...@apache.org> on 2026/10/23 15:52:36 UTC
[I] `MutableArrayData` panics on an `Interval(DayTime)` buffer aligned to 4 bytes [arrow-rs]
mbutrovich opened a new issue, #11862:
URL: https://github.com/apache/arrow-rs/issues/11862
## Describe the bug
`MutableArrayData::new` panics on a valid `Interval(DayTime)` array whose values buffer is 4-byte aligned but not 8-byte aligned. Every kernel that copies through `MutableArrayData`, such as `zip` and `merge`, panics with it.
arrow-rs requires a fixed-width buffer to be aligned only to `align_of` of its native type ([`new_fixed_width`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-data/src/data.rs#L2058-L2063), [`BufferSpec::FixedWidth`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-data/src/data.rs#L2142-L2151)). The spec defines `DAY_TIME` as two contiguous 32-bit signed integers ([Schema.fbs](https://github.com/apache/arrow/blob/373d64c02cb23663b63c5853099fca43a46c39fc/format/Schema.fbs#L407-L410)). arrow-rs represents it as [`IntervalDayTime`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-buffer/src/interval.rs#L348-L355), a `#[repr(C)]` struct of two `i32` fields, so its alignment is 4 and its size is 8. `MutableArrayData` [extends `Interval(DayTime)` as `i64`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-data/src/transform/mod.rs#L259
-L263), so [`build_extend`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-data/src/transform/primitive.rs#L25-L26) reads the buffer as `&[i64]`. [`Buffer::typed_data`](https://github.com/apache/arrow-rs/blob/df4dc3ede59bd43b5f71847231212381d068bb72/arrow-buffer/src/buffer/immutable.rs#L329-L336) then asserts 8-byte alignment.
This is the `DayTime` form of #5917, which #10171 fixed for `MonthDayNano`.
## To Reproduce
On `main` at df4dc3ede59bd43b5f71847231212381d068bb72:
```rust
use arrow_array::{BooleanArray, make_array};
use arrow_buffer::Buffer;
use arrow_data::ArrayData;
use arrow_schema::{DataType, IntervalUnit};
use arrow_select::zip::zip;
fn main() {
// `from_slice_ref` allocates 64-byte aligned memory, so this slice starts at 4 mod 8
let values = Buffer::from_slice_ref([0i32, 1, 2]).slice(4);
// `build` accepts it: the minimum alignment for `Interval(DayTime)` is 4
let data = ArrayData::builder(DataType::Interval(IntervalUnit::DayTime))
.len(1)
.add_buffer(values)
.build()
.unwrap();
let array = make_array(data);
let mask = BooleanArray::from(vec![true]);
// panicked at arrow-buffer/src/buffer/immutable.rs:334:9:
// assertion failed: prefix.is_empty() && suffix.is_empty()
// 4: <arrow_data::data::ArrayData>::buffer::<i64>
// 5: arrow_data::transform::primitive::build_extend::<i64>
zip(&mask, &array, &array).unwrap();
}
```
`MutableArrayData::new(vec![&data], false, 1)` panics the same way.
## Expected behavior
`MutableArrayData` accepts every buffer that `ArrayData::build` accepts. Extending `Interval(DayTime)` as `IntervalDayTime`, as #10171 did for `MonthDayNano`, would do that.
## Additional context
Found while reviewing #11559: https://github.com/apache/arrow-rs/pull/11559#discussion_r4361268730
`extend_nulls` and `ArrayData` equality also handle `Interval(DayTime)` as `i64`. They only use its size, not its alignment, so they don't panic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] `MutableArrayData` panics on an `Interval(DayTime)` buffer aligned to 4 bytes [arrow-rs]
Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid closed issue #11862: `MutableArrayData` panics on an `Interval(DayTime)` buffer aligned to 4 bytes
URL: https://github.com/apache/arrow-rs/issues/11862
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org