Skip to content

Commit 16d5aaa

Browse files
committed
Wait with registering cleanups for locals until after the init code ran
Fixes a double-cleanup that was breaking unwind-tup.rs under valgrind.
1 parent e3626c9 commit 16d5aaa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/comp/middle/trans.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,8 +4676,6 @@ fn trans_be(cx: @block_ctxt, e: @ast::expr) : ast_util::is_call_expr(e) ->
46764676
fn init_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
46774677
let ty = node_id_type(bcx_ccx(bcx), local.node.id);
46784678
let llptr = bcx.fcx.lllocals.get(local.node.id);
4679-
// Make a note to drop this slot on the way out.
4680-
add_clean(bcx, llptr, ty);
46814679

46824680
if must_zero(bcx_ccx(bcx), local) {
46834681
bcx = zero_alloca(bcx, llptr, ty);
@@ -4698,9 +4696,10 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
46984696
}
46994697
_ { }
47004698
}
4701-
bcx =
4702-
trans_alt::bind_irrefutable_pat(bcx, local.node.pat, llptr,
4703-
bcx.fcx.lllocals, false);
4699+
// Make a note to drop this slot on the way out.
4700+
add_clean(bcx, llptr, ty);
4701+
bcx = trans_alt::bind_irrefutable_pat(bcx, local.node.pat, llptr,
4702+
bcx.fcx.lllocals, false);
47044703
ret bcx;
47054704

47064705
fn must_zero(ccx: @crate_ctxt, local: @ast::local) -> bool {

0 commit comments

Comments
 (0)