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
The Arc<RingBuffer> field on Consumer and Producer is made public, which is unsound. Overwriting the buffer field without updating head and tail can cause a read from uninitialized memory without unsafe code in downstream crates.
If the RingBuffer needs to be exposed, then I would recommend a method returning a shared reference instead of a public field.
The text was updated successfully, but these errors were encountered:
I was very unsure when making this field public, but I thought it's fine because the Arc only ever gives read-only access.
However, I didn't realize that the whole field can still be re-assigned!
If the RingBuffer needs to be exposed,
I'm actually not completely sure yet.
For now, a reference to the ring buffer is only needed to get the capacity(), which is a method of the RingBuffer, and not of Producer/Consumer.
However, in the future there might be more methods on RingBuffer, for example mlock()/munlock() (see #3).
I wanted to avoid having to duplicate all methods from RingBuffer on both Producer and Consumer ...
Any suggestions?
then I would recommend a method returning a shared reference instead of a public field.
The
Arc<RingBuffer>
field onConsumer
andProducer
is made public, which is unsound. Overwriting thebuffer
field without updatinghead
andtail
can cause a read from uninitialized memory without unsafe code in downstream crates.If the
RingBuffer
needs to be exposed, then I would recommend a method returning a shared reference instead of a public field.The text was updated successfully, but these errors were encountered: