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

Double drop in Vec::drain_filter #60977

Closed
ExpHP opened this issue May 20, 2019 · 0 comments · Fixed by #61224
Closed

Double drop in Vec::drain_filter #60977

ExpHP opened this issue May 20, 2019 · 0 comments · Fixed by #61224
Labels
A-collections Area: `std::collection` C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ExpHP
Copy link
Contributor

ExpHP commented May 20, 2019

The following playground originally posted by @rustonaut still demonstrates a double drop in Vec::drain_filter. This is unsound.

https://play.rust-lang.org/?gist=be84e0e74bc2eb86d81a7ad90e612ace&version=nightly&mode=debug

Originating comment: #43244 (comment)

@jonas-schievink jonas-schievink added A-collections Area: `std::collection` C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels May 20, 2019
aloucks added a commit to aloucks/rust that referenced this issue May 27, 2019
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jul 4, 2019
Double dropping is unsound (e.g. rust-lang#60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data.
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jul 4, 2019
Double dropping is unsound (e.g. rust-lang#60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data.
bors added a commit that referenced this issue Jul 8, 2019
Prevent Vec::drain_filter from double dropping on panic

Fixes: #60977

The changes in this PR prevent leaking and double-panicking in addition to double-drop.

Tracking issue: #43244
Centril added a commit to Centril/rust that referenced this issue Jul 28, 2019
Document that ManuallyDrop::drop should not called more than once

Double dropping is unsound (e.g. rust-lang#60977). This commit documents the fact that `ManuallyDrop::drop` should not be called multiple times on the same instance, as it might not be immediately obvious that this counts as a use of uninitialized data.
rodrimati1992 added a commit to rodrimati1992/abi_stable_crates that referenced this issue Dec 21, 2020
These methods copied their implementation from the standard library,
which had memory safety bugs discovered in
rust-lang/rust#60977 and rust-lang/rust#78498 .

This bug was reported in #44 .

Added adapted tests from std which test these bugs.
rodrimati1992 added a commit to rodrimati1992/abi_stable_crates that referenced this issue Dec 22, 2020
* Fixed String::retain, RVec::retain. Bumped patch version to 0.9.1 .

These methods copied their implementation from the standard library,
which had memory safety bugs discovered in
rust-lang/rust#60977 and rust-lang/rust#78498 .

This bug was reported in #44 .

Added adapted tests from std which test these bugs.

* Updated changelog for patch
rodrimati1992 added a commit to rodrimati1992/abi_stable_crates that referenced this issue Nov 22, 2022
* Fixed String::retain, RVec::retain. Bumped patch version to 0.9.1 .

These methods copied their implementation from the standard library,
which had memory safety bugs discovered in
rust-lang/rust#60977 and rust-lang/rust#78498 .

This bug was reported in #44 .

Added adapted tests from std which test these bugs.

* Updated changelog for patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: `std::collection` C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants