You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, this is an awesome crate! really cool to see people improving on some of the most popular crates in the ecosystem.
I tried arc-slice in Vortex, where we make very heavy use of Bytes. While it does seem to make a difference in some benchmarks, it also surfaced an issue where spare_capacity_mut is market unsafe here but isn't in bytes. I'm not if compatibility is a major goal here but I figured its worth reporting.
The text was updated successfully, but these errors were encountered:
You're right, spare_capacity_mut is unsafe in the port of bytes using arc-slice, and it was in fact done on purpose, as I suspect BytesMut::spare_capacity_mut to be unsound, and not having it unsafe for ArcSliceMut is definitely unsound.
Why is it unsound? Because spare_capacity_mut, combined with set_len, allows to write uninitialized memory to the buffer.
I'm currently asking if it is an issue for a Vec buffer (that BytesMut is using), but that is clearly an issue for arbitrary buffers, which ArcSliceMut supports. I may also open an issue on bytes repository, depending on the answer I get.
That being said, while in previous drafts I was also storing the Vec buffer directly in the Arc, I made a recent change to store only the pointer + capacity in case of Vec (if needs_drop::<T>() returns false). So technically, I'm protected about the unsoundness of writing uninitialized memory in my BytesMut reimplementation, and I can make BytesMut::spare_capacity_mut safe. I will try to push a new release tonight with this fix, making the API 100% compatible.
In any case, thank you a lot for your feedbacks, and for having tried arc-slice.
First of all, this is an awesome crate! really cool to see people improving on some of the most popular crates in the ecosystem.
I tried
arc-slice
in Vortex, where we make very heavy use ofBytes
. While it does seem to make a difference in some benchmarks, it also surfaced an issue wherespare_capacity_mut
is market unsafe here but isn't inbytes
. I'm not if compatibility is a major goal here but I figured its worth reporting.The text was updated successfully, but these errors were encountered: