-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-7813: [Rust] Remove and fix unsafe code #6395
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
257e947 to
5c8a373
Compare
|
Removed the commits that changed the simd implemented operators. The code is definitely doing undefined behaviour though as the padding won't be initialized ( #6397 (comment) ). So either the code could do non-simd operations for the last partial block (if any). Or the padding should be initialized before reading it. |
I plan to initialize the padded region, ARROW-7836 if no-one beats me to it. |
|
I'll try and review this tomorrow so we can get it merged. |
|
Will take a look too. This needs rebase BTW. And cc @sadikovi . |
|
Ping @Marwes can you re-base this so we can review if you get a chance please? |
|
@Marwes Could you rebase this ? |
|
Rebased, CI is failing though. Not sure what to do to fix. |
|
This was fixed by #6800. Let me see if I can re-trigger CI. |
|
@kszucs how can I re-trigger CI? I tried to force-push to this branch but it has no effect. |
|
Not sure what happened with GitHub (they have been having outage issues?) but I rebased and CI is running again |
|
CI is failing with |
|
@Marwes looks like just some basic issues with this, want to take a quick look? I'd like to get this one merged. |
|
(I was "invited" to look at this PR, since I noticed some issues that needed fixing. All my comments will appear a bit random and semi-related to this PR, because of this. I will only comment on important issues.) Nice, I had named 3 things I saw in arrow 0.16.0 code (not a full review) Issue (1) about Buffer.ptr being null is being fixed here in this PR. Another common way to solve this in Rust is to use https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.dangling - an aligned non-null dummy pointer, but I won't review this solution further, Marwes can probably judge it all as well as I can. Using Issue (2) so remains, no check for allocation failure. This produces dangerous mismatches - null pointer and nonzero length - in various places. This doesn't have to be fixed in this PR, just to note that the issue is not fixed here. |
rust/arrow/src/buffer.rs
Outdated
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
rust/arrow/src/buffer.rs
Outdated
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
rust/arrow/src/buffer.rs
Outdated
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
This fix has disappeared, I can't see it in the diff anymore 😕
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.
I opened ARROW-8479
Might be other platforms this works on as well, but those could be added as they are found
Fixes undefined behaviour that could occur from safe code calling with `T == Box<i32>` etc.
This may cause panics in code using ByteArray or Int96 but no tests currently test these paths. Still better than the status quo which would be undefined behaviour (if the replaced code paths were hit).
Some types such as `&[Int96]` and `&[ByteArray]` can't be transmuted to a `&[u8]` as they aren't plain old data. `&mut bool` can't be transmuted to a `&mut u8` since that would allow writing values other than 0 or 1 to it.
That's the better solution. I just spotted the null pointer issue late in this PR and didn't want to complicate it further. Fixed the review comments. |
|
Thank you @Marwes for doing big work like this for better and safer code |
paddyhoran
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.
|
Would be great to get this into 0.17.0, probably needs to be merged today cc @kszucs |
sunchao
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.
+1. I only had time to skim through this but it'd be great if we have some perf numbers to show there is no regression.
|
@sunchao Included in the 0.17 release. If you find a significant regression, then we can still fix it by cutting a new release candidate. |
This removes or corrects many instances of unsafe code in the rust crates. This is by no means a complete fix and some of the fixes do not entirely fix the issues with the particular
unsafe(see comments), but in all instances it should put the code in a better place than before.Based on #6256