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

Drop struct fields if the user destructor fails #10219

Merged
merged 1 commit into from
Nov 3, 2013

Conversation

alexcrichton
Copy link
Member

This commit changes drop glue generated for structs to use the invoke LLVM
instruction instead of call. What this means is that if the user destructor
triggers an unwinding, then the fields of the struct will still ge dropped.

This is not an attempt to support failing while failing, as that's mostly a
problem of runtime support. This is more of an issue of soundness in making sure
that destructors are appropriately run. The test included fails before this
commit, and only has one call to fail!(), yet it doesn't destroy its struct
fields.

This commit changes drop glue generated for structs to use the invoke LLVM
instruction instead of call. What this means is that if the user destructor
triggers an unwinding, then the fields of the struct will still ge dropped.

This is not an attempt to support failing while failing, as that's mostly a
problem of runtime support. This is more of an issue of soundness in making sure
that destructors are appropriately run. The test included fails before this
commit, and only has one call to fail!(), yet it doesn't destroy its struct
fields.
@brson
Copy link
Contributor

brson commented Nov 1, 2013

This may fix the original problem reported in #910 (though that issues has morphed into complaints about other things). Does run-fail/unwind-resource-fail2.rs work now?

@alexcrichton
Copy link
Member Author

That test actually invokes fail!() twice, the first triggers unwinding and then while unwinding a second fail!() is triggered in the destructor, so this doesn't help dealing with that problem (sadly).

bors added a commit that referenced this pull request Nov 3, 2013
This commit changes drop glue generated for structs to use the invoke LLVM
instruction instead of call. What this means is that if the user destructor
triggers an unwinding, then the fields of the struct will still ge dropped.

This is not an attempt to support failing while failing, as that's mostly a
problem of runtime support. This is more of an issue of soundness in making sure
that destructors are appropriately run. The test included fails before this
commit, and only has one call to fail!(), yet it doesn't destroy its struct
fields.
@bors bors closed this Nov 3, 2013
@bors bors merged commit e35cd96 into rust-lang:master Nov 3, 2013
@alexcrichton alexcrichton deleted the drop-invoke branch November 4, 2013 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants