Skip to content
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

Make OwnedRepr an "aliasable owner" instead of using Vec #799

Merged
merged 2 commits into from
Apr 18, 2020
Merged

Conversation

bluss
Copy link
Member

@bluss bluss commented Apr 15, 2020

The owned array has used a Vec<T> that it owns, and kept a separate "head pointer" ptr on the side; the head pointer points to the first element in the array, somewhere inside the vector's data.

The Vec uses a "unique" owning pointer - not a building block that is available outside std - so just like Box, it should in principle not be possible to modify the vector's data through anything else than its own data pointer. Our head pointer can violate this.

We replace the Vec with a deconstructed vector; it's equivalent but uses NonNull<T> for its pointer, so it's an aliasable owner.

This does not change how owned arrays are allocated, only how it is modelled in the type system. The change affects all the owned arrays (Array, ArcArray, CowArray).

cc #796

In principle, this problem is described in issue Kimundi/owning-ref-rs#49

This soundness concern does not currently seem to yield any problems in practice, because the compiler does not take advantage of the properties of Vec's unique pointer.

bluss added 2 commits April 15, 2020 19:01
Avoid the unique ownership meaning of Vec by storing the fields raw in
our own representation. Supply conversion to/from Vec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant