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

Use ManuallyDrop with bumpalo's Box instead of mem::forget #188

Merged
merged 1 commit into from Nov 29, 2022

Conversation

saethlin
Copy link
Contributor

Miri now reports UB with some uses of bumpalo's Box where it did not before: rust-lang/miri#2704

The previous behavior of Miri was a false negative. rustc applies noalias to newtype wrappers around &mut, so Miri has to retag &mut when passed by value to a function even if it is in a wrapper struct, such as bumpalo's Box. mem::forget is a common aliasing footgun, because for a unique-owning wrapper like Box, leaking an RAII handle re-asserts the uniqueness of the handle as it is sent to the void. Ouch.

ManuallyDrop solves this problem.

Closes #187

Miri now reports UB with some uses of bumpalo's Box where it did not
before: rust-lang/miri#2704

The previous behavior of Miri was a false negative. rustc applies
noalias to newtype wrappers around &mut, so Miri has to retag &mut when
passed by value to a function even if it is in a wrapper struct, such as
bumpalo's Box. mem::forget is a common aliasing footgun, because for a
unique-owning wrapper like Box, leaking an RAII handle re-asserts the
uniqueness of the handle as it is sent to the void. Ouch.

ManuallyDrop solves this problem.
Copy link
Owner

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

Thanks!

@fitzgen fitzgen merged commit b1e67b7 into fitzgen:main Nov 29, 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.

Miri Stacked Borrows violation after replacing std::boxed::Box with bumpalo::boxed::Box
2 participants