You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tv42 (via GitHub)" <gi...@apache.org> on 2025/03/04 19:59:53 UTC

[I] Builder `reserve` methods should be marked `unsafe` [arrow-rs]

tv42 opened a new issue, #7236:
URL: https://github.com/apache/arrow-rs/issues/7236

   **Describe the bug**
   
   https://docs.rs/arrow/latest/arrow/array/struct.BooleanBufferBuilder.html#method.reserve says
   
   > `pub fn reserve(&mut self, additional: usize)`
   > Reserve space to at least `additional` new bits. Capacity will be `>= self.len() + additional`. New bytes are uninitialized and reading them is undefined behavior.
   
   Other `reserve` methods look similar, but don't document their undefined behavior; I haven't carefully read the code on whether they actually are unsafe or not.
   
   It seems this is letting the caller trigger undefined behavior, but is not marked as `unsafe`.
   
   Their documentation should probably also be unified.
   
   - [BooleanBufferBuilder::reserve](https://docs.rs/arrow/latest/arrow/array/struct.BooleanBufferBuilder.html#method.reserve)
   - [OffsetBufferBuilder::reserve](https://docs.rs/arrow/latest/arrow/array/struct.OffsetBufferBuilder.html#method.reserve)
   - [BufferBuilder.html::reserve](https://docs.rs/arrow/latest/arrow/array/struct.BufferBuilder.html#method.reserve)
   - [MutableBuffer::reserve](https://docs.rs/arrow/latest/arrow/buffer/struct.MutableBuffer.html#method.reserve)


-- 
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] Remove Misleading BooleanBufferBuilder::reserve Doc [arrow-rs]

Posted by "WaterWhisperer (via GitHub)" <gi...@apache.org>.
WaterWhisperer commented on issue #7236:
URL: https://github.com/apache/arrow-rs/issues/7236#issuecomment-3701579178

   take


-- 
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


Re: [I] Remove Misleading BooleanBufferBuilder::reserve Doc [arrow-rs]

Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed issue #7236: Remove Misleading BooleanBufferBuilder::reserve Doc
URL: https://github.com/apache/arrow-rs/issues/7236


-- 
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


Re: [I] Builder `reserve` methods should be marked `unsafe` [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #7236:
URL: https://github.com/apache/arrow-rs/issues/7236#issuecomment-2698899133

   > It seems this is letting the caller trigger undefined behavior, but is not marked asĀ unsafe.
   
   I think the docs are potentially misleading, it is undefined behaviour to read the allocated bytes, but the only way to so is using unsafe code.
   
   


-- 
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


Re: [I] Remove Misleading BooleanBufferBuilder::reserve Doc [arrow-rs]

Posted by "tv42 (via GitHub)" <gi...@apache.org>.
tv42 commented on issue #7236:
URL: https://github.com/apache/arrow-rs/issues/7236#issuecomment-2699151641

   Ah yes, `as_slice` only exposes up to `self.len` etc.


-- 
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