-
Notifications
You must be signed in to change notification settings - Fork 4
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
misaligned pointer dereference #9
Comments
I get this also. This is a new check in rust that was previous undefined behavior, I think. Newly released in 1.7 I don't know a lot about it but it seems like one way to solve the problem is using read_unaligned I believe that in the function with the problem, you could possibly replace the *proc_ev with proc_ev.read_unaligned()? I might try this if I get a minute and submit a PR
|
We don't have direct control of
The assertion is about being aligned to 8-bytes boundary, which makes it necessary for |
Sure, but the actual problem happens when you try to reference *proc_ev You can replace every instance of that with I haven't looked into it enough to see if there's a concern here, i.e. if the alignment problem represents some kind of underlying bug, but, doing this should in theory be the same behavior as before Rust changed their alignment rules in derefs (which also could have been incorrect, but in my (limited) experimentation seems to work OK) I'll submit a PR after xmas and maybe some other people can try it out or let me know if something is wrong with it |
It does prevent the alignment problem, but replacing every pointer dereference by a bitwise copy of the entire struct, just to each time access one field, is a bit of a waste. It is a bit better to use a single But then there is still an extra copy involved, which maybe we could get rid of by getting a proper alignment to start with. Or shouldn't we rely on a proven deserialization library instead of all this manual unsafe parsing? |
I have a fix for the alignment issue, but I'm not satisfied with it either: it really looks like a case where we should rather want to use scatter/gather |
When I run the example code, I get:
Backtrace:
I guess this has something to do with alignment of the C structs, and my system happens to hit an edge case. In my own
<linux/connector.h>
, I have:However the bindgen doesn't seem to capture this:
cnproc-rs/src/binding.rs
Lines 1072 to 1079 in 3d8f058
The text was updated successfully, but these errors were encountered: