-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-10448: [Rust] Remove PrimitiveArray::new that can cause UB #8560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think we have a similar problem with building arrays from So something like the below gets created, but ends up as a 0-len array // try build array data without specifying length
ArrayData::builder(DataType::_).buffers(vec![buffer1, buffer2]).build() |
That is a very good point. I think that we have a trade-off here: do we check that the This could be a good topic for the mailing list, as it is a general question, specially for IPC and the c data interface. |
|
Is it the case that "UB" means "Undefined Behavior"? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good improvement to me. 👍 It also makes it clearer to people how to construct arrays (aka use the Builders) rather than also potentially using PrimitiveArray::new directly
nevi-me
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR removes
PrimitiveArray::new.PrimitiveArray::newispub, but it is dangerous because:null_count > 0, many calls panic as the null bitmap isNone, but thenull_count != 0null_count > 0, it creates an array out of spec (as the buffer for the null bitmap isNonebut the null count is not zero)Since:
null_count) requires a backward incompatible changeThis PR removes it.