Skip to content

Commit f022f56

Browse files
author
Elliott Slaughter
committed
rt: Fix box annihilator to deallocate exchange heap boxes properly.
1 parent f8323ac commit f022f56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rt/rust_box_annihilator.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ annihilator::do_annihilate(rust_task *task, rust_opaque_box *box) {
197197
annihilator annihilator(task, true, tydesc->shape,
198198
tydesc->shape_tables, p);
199199
annihilator.walk();
200-
task->boxed.free(box);
200+
// NB: A reference count of -1 indicates that this box lives on the
201+
// exchange heap. Otherwise it lives on the task-local heap.
202+
if (box->ref_count + 1 == 0) {
203+
task->kernel->free(box);
204+
} else {
205+
task->boxed.free(box);
206+
}
201207
}
202208

203209
void

0 commit comments

Comments
 (0)