-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Assignments leave their place partially-destroyed if the destructor panics #30380
Copy link
Copy link
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)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/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)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/SoundnessP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
STR
Results
The assignment to
*b.0withinfoocalls the drop-glue for the value inside. The new tuple("~", Bomb)is created, and then the drop glue for the old value ofbis executed. It first frees the original string, and then attempts to callsBomb's destructor. As the latter destructor panics, the function unwinds without storing a value in the place of the missingString, leaving a&mutreference that points to an invalid value, which can later be observed by a destructor orrecover.Fixes
The new value for the destination is available the whole time - the panic handler can just write it in.