-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
VecDeque's Drain::drop writes to memory that a shared reference points to #60076
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
liballoc's
test_drainfails when run in Miri. The error occurs in thedrain(...).collect()call:collectis called with avec_deque::Drain<usize>as argument.DraincontainsItercontains a shared reference to a slice; that slice is thus marked as "must not be mutated for the entire duration of this function call".collectcallsfrom_itercallsextendcallsfor_eachcallsfold, which eventually drops theDrain.Drain::dropcallssource_deque.wrap_copyto re-arrange stuff (I have not fully understood this yet), and in some cases this will end up writing to memory that the slice inIterpoints to.I am not sure what the best way to fix this is. We have to fix
Drainholding (indirectly) a shared reference to something that it'll mutate during itsDrop. The mutation is likely there for a reason, so I guess the shared reference has to go. (FWIW, this shared reference already caused other trouble, but that was fixed by #56161.)Cc @nikomatsakis @gankro