You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Ruby] Wrong data pointer in MemoryView of a sliced array #52021
Describe the bug, including details regarding any error messages, version, and platform.
For a sliced primitive array, the data pointer of the exported
MemoryView is advanced by offset bytes instead of offset × element size bytes, so values wider than one byte come
out wrong (no error is raised).
The cause is GetValuesSafe<uint8_t>(1) in PrimitiveArrayGetter::fill
(ext/arrow/memory-view.cpp): it adds the offset in units of uint8_t.
The offset should be scaled by the element width.
A possible fix is to take the buffer start and scale the offset by the
element width:
constauto type =
std::static_pointer_cast<const arrow::FixedWidthType>(array.type());
view_->item_size = type->bit_width() / 8;
constauto base = array_data->GetValuesSafe<uint8_t>(1, 0);
constauto data = base + array_data->offset * view_->item_size;
view_->data = const_cast<void *>(reinterpret_cast<constvoid *>(data));
view_->byte_size = view_->item_size * array.length();
Thanks for the quick fix! I applied #52286 to red-arrow 25.0.1 locally and ran the tests of a library that reads Arrow arrays through MemoryView. Sliced arrays now read correctly, including slices of slices and the indices of a sliced dictionary array. Looks good to me.
Activity
gitedmond commentedon Oct 7, 2026
@himotoyoshi I have a fix up in #52286. Let me know if you have any feedback!
himotoyoshi commentedon Oct 8, 2026
Thanks for the quick fix! I applied #52286 to red-arrow 25.0.1 locally and ran the tests of a library that reads Arrow arrays through MemoryView. Sliced arrays now read correctly, including slices of slices and the indices of a sliced dictionary array. Looks good to me.
apacheGH-52021: [Ruby] Address MemoryView review feedback
GH-52021: [Ruby] Add support for sliced arrays in MemoryView (#52286)
kou commentedon Oct 9, 2026
Issue resolved by pull request 52286
#52286