-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 in-place collection leak when remaining element destructor panic #101642
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this passes miri?
You should also update the "Drop- and panic-safety" section in the module docs. |
85d7c44
to
dad049c
Compare
I'm having a bit of trouble running miri tests with the modified stdlib since I'm on windows, but I think I'm getting there. |
Ok I managed to run it after some problems with invalid language items but in the end it worked and the test passes. |
I'm not too familiar with the PR process for this repository. I marked the changes as approved, because from my perspective they are good and complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran some vec benches locally and didn't see any changes, so this should be good. Plus there are some codegen tests covering primitives (but not U: Drop) that ensure it optimizes in the ideal case so from a perspective this should be fine.
With the test and miri passing it should be fine too from the safety perspective.
It seems pretty straight-forward.
- pass ownership from IntoIter to InPlaceDstBufDrop
- drop src (can panic)
- drop sink (on panic) (can panic)
- if not panic: pass ownership to final vec
So at no time there's duplicate ownership while things can panic.
So there are only a few minor things left about the comments
fb01af3
to
1750c7b
Compare
@bors r+ |
Rollup of 6 pull requests Successful merges: - rust-lang#101189 (Implement `Ready::into_inner()`) - rust-lang#101642 (Fix in-place collection leak when remaining element destructor panic) - rust-lang#102489 (Normalize substs before resolving instance in `NoopMethodCall` lint) - rust-lang#102559 (Don't ICE when trying to copy unsized value in const prop) - rust-lang#102568 (Lint against nested opaque types that don't satisfy associated type bounds) - rust-lang#102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #101628
cc @the8472
I went for the drop guard route, placing it immediately before the
forget_allocation_drop_remaining
call and after the comment, as to signal they are closely related.I also updated the test to check for the leak, though the only change really needed was removing the leak clean up for miri since now that's no longer leaked.