-
Notifications
You must be signed in to change notification settings - Fork 50
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
Unsoundness in OwningRef::map_with_owner
and more
#77
Comments
Open
This repo has not received any commits for two years (since Feb 27, 2020) and seems unmaintained. Did you try to contact the owners directly? |
This was referenced Aug 3, 2022
Hey everyone, since so long has passed and still the maintainer hasn't showed up and no one made a replacement crate, I decided to make my pull request into a crate. It's available as |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found more unsoundness problems. This extends #61 .
In particular,
OwningRef::map_with_owner
allows creating anOwningRef
that points at the owner, which can be moved.This by itself can be fixed by replacing
map_with_owner
with a method that only gives out a reference to the referent of the owner, like this:In addition, There's unsoundness combining a conversion from
OwningRefMut
toOwningRef
together with methods that can read the owner of anOwningRef
, like so:OwningRefMut::{as_owner, as_owner_mut}
can also be used, as #61 shows.There are two ways to fix this, and each choice corresponds to a small difference in the meaning and invariants of
OwningRef
:OwningRefMut
toOwningRef
, and allow shared access to the owner of anOwningRef
.Invariant: the reference of the
OwningRef
may only borrow immutably from the owner.OwningRefMut
toOwningRef
, but disallow shared access to the owner of anOwningRef
.Invariant: the reference of the
OwningRef
may borrow immutably or mutably from the owner.Essentially, these are two distinct types, which are both sound by themselves, and a third option is to have both types.
The text was updated successfully, but these errors were encountered: