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

Fix trans coercions of Box<[T]> and Box<Trait> in match arms #21692

Merged
merged 3 commits into from
Jan 30, 2015

Conversation

pnkfelix
Copy link
Member

trans: When coercing to Box<Trait> or Box<[T]>, leave datum in it's original L-/R-value state.

This fixes a subtle issue where temporaries were being allocated (but not necessarily initialized) to the (parent) terminating scope of a match expression; in particular, the code to zero out the temporary emitted by datum.store_to is only attached to the particular match-arm for that temporary, but when going down other arms of the match expression, the temporary may falsely appear to have been initialized, depending on what the stack held at that location, and thus may have its destructor erroneously run at the end of the terminating scope.

FIx #20055.

(There may be a latent bug still remaining in fn into_fat_ptr, but I am so annoyed by the test/run-pass/coerce_match.rs failures that I want to land this now.)

…s original L-/R-value state.

This fixes a subtle issue where temporaries were being allocated (but
not necessarily initialized) to the (parent) terminating scope of a
match expression; in particular, the code to zero out the temporary
emitted by `datum.store_to` is only attached to the particular
match-arm for that temporary, but when going down other arms of the
match expression, the temporary may falsely appear to have been
initialized, depending on what the stack held at that location, and
thus may have its destructor erroneously run at the end of the
terminating scope.

Test cases to appear in a follow-up commit.

Fix rust-lang#20055
Note that I have not yet managed to expose any bug in
`trans::expr::into_fat_ptr`; it would be good to try to do so (or show
that the use of `.to_lvalue_datum` there is sound).
@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@eddyb
Copy link
Member

eddyb commented Jan 27, 2015

@bors r+ 5b66c6d

Fix the issue-20055-box-trait.rs test to actually test `Box<Trait>`.

Fix rust-lang#21695.
@pnkfelix
Copy link
Member Author

@bors r=eddyb d855202

bors added a commit that referenced this pull request Jan 29, 2015
trans: When coercing to `Box<Trait>` or `Box<[T]>`, leave datum in it's original L-/R-value state.

This fixes a subtle issue where temporaries were being allocated (but not necessarily initialized) to the (parent) terminating scope of a match expression; in particular, the code to zero out the temporary emitted by `datum.store_to` is only attached to the particular match-arm for that temporary, but when going down other arms of the match expression, the temporary may falsely appear to have been initialized, depending on what the stack held at that location, and thus may have its destructor erroneously run at the end of the terminating scope.

FIx #20055.

(There may be a latent bug still remaining in `fn into_fat_ptr`, but I am so annoyed by the test/run-pass/coerce_match.rs failures that I want to land this now.)
@bors
Copy link
Contributor

bors commented Jan 29, 2015

⌛ Testing commit d855202 with merge 52c74e6...

@richo
Copy link
Contributor

richo commented Jan 30, 2015

ooc, is this related to the failure I've been seeing on OSX for a while?

failures:
    [run-pass] run-pass/coerce-match-calls.rs
    [run-pass] run-pass/coerce-match.rs

(There's no output, it just fails).

@bors bors merged commit d855202 into rust-lang:master Jan 30, 2015
@pnkfelix
Copy link
Member Author

@richo yes, this is meant to fix that.

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.

Panic during unit tests (coerce_match)
5 participants