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

Fix theoretical UB while transmuting Arc #588

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

niklasf
Copy link
Contributor

@niklasf niklasf commented Jan 19, 2022

As far as I can tell, there is no guarantee that Arc<T> can be soundly transmuted to Arc<U>, even if T can be soundly transmuted to U.

Looking at the implementation of Arc, it is effectively a single field struct, wrapping a private NonNull<ArcInner<T>> where ArcInner<T> is #[repr(C)], so the transmute is not UB as of now, and of course it's unlikely that this would change. But it's still not good to rely on such an implementation detail for soundness.

Copy link
Member

@stanislav-tkach stanislav-tkach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thank you!

@aleksuss aleksuss merged commit 4f69589 into rust-rocksdb:master Feb 2, 2022
vldm pushed a commit to velas/rust-rocksdb that referenced this pull request Sep 8, 2022
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.

None yet

3 participants