kawadakk opened a new issue, #5412: URL: https://github.com/apache/arrow-rs/issues/5412
**Describe the bug** When overflow checks are disabled, `<Buffer as FromIterator<T>>::from_iter` may construct `MutableBuffer` with a smaller capacity due to wrap-around arithmetic, causing out-of-bounds write. <https://github.com/apache/arrow-rs/blob/5bb226cc791adfd6903497cbb8fcd8285fe6f298/arrow-buffer/src/buffer/immutable.rs#L424-L438> <https://github.com/apache/arrow-rs/blob/5bb226cc791adfd6903497cbb8fcd8285fe6f298/arrow-buffer/src/buffer/mutable.rs#L71-L72> <https://github.com/apache/arrow-rs/blob/5bb226cc791adfd6903497cbb8fcd8285fe6f298/arrow-buffer/src/util/bit_util.rs#L32-L43> **To Reproduce** The following code segfaults in release build: ```rust // Trigger wrap-wround in `Buffer::from_iter` arrow_buffer::buffer::Buffer::from_iter( std::iter::repeat(42u64).take(usize::MAX / std::mem::size_of::<u64>() + 1)); ``` ```rust // Trigger wrap-wround in `bit_util::round_upto_multiple_of_64` arrow_buffer::buffer::Buffer::from_iter( std::iter::repeat(42u64).take(usize::MAX / std::mem::size_of::<u64>())); ``` **Expected behavior** Panicking, aborting, or successful UB-free execution **Additional context** <!-- Add any other context about the problem here. --> -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
