Skip to content

Commit db6a62c

Browse files
committed
rustc: Drop the visitor object from the visitor glue
Recent demoding makes the visitor glue leak. It hasn't shown up in tests because the box annihilator deletes the leaked boxes. This affects the new scheduler though which does not yet have a box annihilator. I don't think there's any great way to test this besides setting up a task that doesn't run the box annihilator and I don't know that that's a capability we want tasks to have.
1 parent 9847428 commit db6a62c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc/middle/trans/glue.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,15 @@ pub fn call_tydesc_glue(cx: block, v: ValueRef, t: ty::t, field: uint)
394394

395395
pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
396396
let _icx = bcx.insn_ctxt("make_visit_glue");
397-
let mut bcx = bcx;
398-
let (visitor_trait, object_ty) = ty::visitor_object_ty(bcx.tcx());
399-
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), object_ty)));
400-
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
397+
let bcx = do with_scope(bcx, None, ~"visitor cleanup") |bcx| {
398+
let mut bcx = bcx;
399+
let (visitor_trait, object_ty) = ty::visitor_object_ty(bcx.tcx());
400+
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), object_ty)));
401+
bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, visitor_trait.def_id);
402+
// The visitor is a boxed object and needs to be dropped
403+
add_clean(bcx, v, object_ty);
404+
bcx
405+
};
401406
build_return(bcx);
402407
}
403408

0 commit comments

Comments
 (0)