-
Notifications
You must be signed in to change notification settings - Fork 676
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
AioCb::from_boxed_slice violates mutability guarantees #788
Comments
@asomers Any progress with this? Been over a month and if this is trivial, I know you wanted the 0.10 release was supposed to happen quickly. It's only blocking on this. |
The problem is a good solution isn't trivial. It's a question of what we want a good I've been grappling with this question, but there's no perfect answer. Should we just remove |
Why is there a problem with pulling in new dependencies? If that allows us to offer a nice and safe API, what are the technical reasons not to do so? |
Bloat. Bloat is the only reason. BTW, the three required crates would be bytes, iovec, and byteorder. |
Bloat isn't a technical reason tho. What defines bloat and why is it bad? It's hard to make a technical decision when some of the information you're judging to make that decision isn't technical. So until I hear technical reasons, I'm inclined to say that's the best solution as I see no technical downsides to its implementation. |
It's not actually safe to read into an `Rc<[u8]>`. It only worked because of a coincidental `unsafe` block. Replace that type with `BytesMut` from the bytes crate. For consistency's sake, use `Bytes` for writing too, and completely remove methods relating to `Rc<[u8]>`. Note that the `AioCb` will actually own the `BytesMut` object. The caller must call `into_buffer` to get it back once the I/O is complete. Fixes nix-rust#788
Fixed in #820. It looks like GitHub doesn't auto-close issues when referenced from commits, only PR bodies. Lame. |
Turns out it's not safe to use aio_read with an Rc<Box<[u8]>>. Instead, use Bytes and BytesMut from the bytes crate. Add LioCb::{emplace_bytes,emplace_bytes_mut} Fallout from nix-rust/nix#788
An
Rc<Box<[u8]>>
does not have interior mutability. It's supposed to be impossible to update its contents. ButAioCb::from_boxed_slice
current allows you to. It does it by casting a*const c_void
to a*mut c_void
. Technically, that's a safe operation. The only unsafe part is when you dereference the pointer. But we have to do that in anunsafe
block anyway, so the compiler never alerted us to the mutability problem.Fixing this issue is trivial. The problem is that nix's consumers may be relying on this behavior.
The text was updated successfully, but these errors were encountered: