about summary refs log tree commit diff
path: root/src/rt/rust_box_annihilator.cpp
diff options
context:
space:
mode:
authorElliott Slaughter <eslaughter@mozilla.com>2012-08-31 10:43:57 -0700
committerElliott Slaughter <eslaughter@mozilla.com>2012-08-31 15:10:52 -0700
commitf022f566a437819d5b41903fa0c59471cd3c7491 (patch)
tree4b6b6fd5054ae013c44303efda858a24adb457dd /src/rt/rust_box_annihilator.cpp
parentf8323ac6156fd3234a94351a4104a1203bd83df1 (diff)
rt: Fix box annihilator to deallocate exchange heap boxes properly.
Diffstat (limited to 'src/rt/rust_box_annihilator.cpp')
-rw-r--r--src/rt/rust_box_annihilator.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rt/rust_box_annihilator.cpp b/src/rt/rust_box_annihilator.cpp
index 91f6f853107..be93b7d4239 100644
--- a/src/rt/rust_box_annihilator.cpp
+++ b/src/rt/rust_box_annihilator.cpp
@@ -197,7 +197,13 @@ annihilator::do_annihilate(rust_task *task, rust_opaque_box *box) {
     annihilator annihilator(task, true, tydesc->shape,
                             tydesc->shape_tables, p);
     annihilator.walk();
-    task->boxed.free(box);
+    // NB: A reference count of -1 indicates that this box lives on the
+    // exchange heap. Otherwise it lives on the task-local heap.
+    if (box->ref_count + 1 == 0) {
+        task->kernel->free(box);
+    } else {
+        task->boxed.free(box);
+    }
 }
 
 void