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

An InlineExtent can be modified without locking the Tree #74

Open
asomers opened this issue May 21, 2021 · 0 comments
Open

An InlineExtent can be modified without locking the Tree #74

asomers opened this issue May 21, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@asomers
Copy link
Collaborator

asomers commented May 21, 2021

Tree::get is supposed to return by value, not by reference. But InlineExtent (and ExtAttr::Inline) values contain an embedded Arc<DivBufShared>. So if calling code, for example in Fs::do_truncate, gets such a value via Tree::get, it can mutate the Arc-protected buffer that is still owned by the Tree. The result is a mutation of an unlocked Tree, which is not good.

Rust's type system should be used to prevent this unlocked mutation, perhaps by returning something more like an Arc<[u8]>. Or, perhaps Tree::get should refuse to return such a value, and there should be a method like Tree::with that can access the Value while still holding the Tree's leaf node locked.

@asomers asomers added the bug Something isn't working label May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant