You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/04 15:09:01 UTC

[GitHub] [arrow-rs] alamb edited a comment on issue #996: Remove unsafe from Buffer::typed_data

alamb edited a comment on issue #996:
URL: https://github.com/apache/arrow-rs/issues/996#issuecomment-986042173


   I reviewed the code a bit more, and the comments make a great point:
   
   ```
       /// `ArrowNativeType` is public so that it can be used as a trait bound for other public
       /// components, such as the `ToByteSlice` trait.  However, this means that it can be
       /// implemented by user defined types, which it is not intended for.
   ```
   
   Meaning that if a user implements `ArrowNativeType` for their types, this will result in undefined behavior. 
   
   I also looked more carefully at Buffer and it effectively allows reinterpreting arbitrary `bytes` as different types, so I am not sure that behavior is safe...
   
   What could 
    be done is make `MutableBuffer::typed_data` unsafe instead as the docs there say very specifically 
   
   ```
       /// # Safety
       /// This function must only be used when this buffer was extended with items of type `T`.
       /// Failure to do so results in undefined behavior.
   ```


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