Skip to content

Fix double-drop in Vec::from_iter(vec.into_iter()) specialization when items drop during panic#83629

Closed
the8472 wants to merge 3 commits intorust-lang:masterfrom
the8472:fix-inplace-panic-on-drop
Closed

Fix double-drop in Vec::from_iter(vec.into_iter()) specialization when items drop during panic#83629
the8472 wants to merge 3 commits intorust-lang:masterfrom
the8472:fix-inplace-panic-on-drop

Conversation

@the8472
Copy link
Member

@the8472 the8472 commented Mar 29, 2021

This fixes the double-drop but it leaves a behavioral difference compared to the default implementation intact: In the default implementation the source and the destination vec are separate objects, so they get dropped separately. Here they share an allocation and the latter only exists as a pointer into the former. So if dropping the former panics then this fix will leak more items than the default implementation would. Is this acceptable or should the specialization also mimic the default implementation's drops-during-panic behavior?

Fixes #83618

@rustbot label T-libs-impl

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Double free in Vec::from_iter specialization when drop panics

10 participants