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

PinnedDrop implementations can contain unsafe code without an unsafe block #148

Closed
sfackler opened this issue Oct 17, 2019 · 5 comments · Fixed by #149
Closed

PinnedDrop implementations can contain unsafe code without an unsafe block #148

sfackler opened this issue Oct 17, 2019 · 5 comments · Fixed by #149
Assignees
Labels
A-drop Area: #[pinned_drop] and Drop C-bug Category: related to a bug. I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness

Comments

@sfackler
Copy link

Since the #[pinned_drop] attribute injects an unsafe onto the drop fn, code within the drop implementation can perform unsafe operations without an explicit unsafe block.

You could potentially instead generate something like

impl PinnedDrop for Foo {
    unsafe fn drop(self: Pin<&mut Self>) {
        fn drop_inner(self: Pin<&mut Self>) {
            // user code here
        }
        drop_inner(self);
    }
}
@Aaron1011
Copy link
Collaborator

Aaron1011 commented Oct 17, 2019

This is what my original PR did, for exactly this reason. It looks like this got changed at some point.

@taiki-e
Copy link
Owner

taiki-e commented Oct 17, 2019

@sfackler Thanks for finding this! Seems I accidentally changed this in #86...
I will fix this soon.

@taiki-e taiki-e self-assigned this Oct 17, 2019
@taiki-e taiki-e added A-drop Area: #[pinned_drop] and Drop C-bug Category: related to a bug. labels Oct 17, 2019
@bors bors bot closed this as completed in 1b256cf Oct 17, 2019
@bors bors bot closed this as completed in #149 Oct 17, 2019
@taiki-e
Copy link
Owner

taiki-e commented Oct 17, 2019

Published 0.4.4 which fixes this issue.

@taiki-e
Copy link
Owner

taiki-e commented Oct 17, 2019

(And yanked 0.4.0 - 0.4.3 which have this bug)

@sfackler
Copy link
Author

Thanks!

@taiki-e taiki-e added the I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness label Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-drop Area: #[pinned_drop] and Drop C-bug Category: related to a bug. I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
Projects
None yet
3 participants