jorgecarleitao opened a new pull request #8901:
URL: https://github.com/apache/arrow/pull/8901


   I would like to propose that we outline and enforce guidelines on the arrow 
crate implementation with respect to the usage of `unsafe`.
   
   The background of this proposal are PRs #8645 and #8829. In both cases, 
while addressing an unrelated issue, they hit undefined behavior (UB) due to an 
incorrect usage of `unsafe` in the code base. This UB was very time-consuming 
to identify and debug: combined, they accounted for more than 12hs of my time.
   
   Safety against undefined behavior is the core premise of the Rust language. 
In many cases, the maintenance burden (time to find and fix bugs) does not 
justify the performance improvements and the decrease in motivation in handling 
them (they are just painful due to how difficult they are to debug). In 
particular, IMO those 12 hours would have been better spent in other parts of 
the code if `unsafe` would have not been used in the first place, which would 
have been likely translated in faster code or more features.
   
   There are situations where `unsafe` is necessary, and the guidelines outline 
these cases. However, I also see many uses of `unsafe` that are not necessary 
nor properly documented.
   
   The goal of these guidelines is to motivate contributors of the Rust 
implementation to be conscious about the maintenance cost of `unsafe`, and 
outline specific necessary conditions for any new `unsafe` to be introduced in 
the code base.


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to