From 75ab8732386096a77113514f767e134e42a5435f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 17 Aug 2016 12:14:09 -0700 Subject: 3212 - bugfix in refcount management When updating refcounts for a typed segment of memory being copied over with another, we were only ever using the new copy's data to determine any tags for exclusive containers. Looks like the right way to do refcounts is to increment and decrement separately. Hopefully this is a complete fix for the intermittent but non-deterministic errors we've been encountering while running the edit/ app. --- 037abandon.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to '037abandon.cc') diff --git a/037abandon.cc b/037abandon.cc index 2c681f7f..014747d7 100644 --- a/037abandon.cc +++ b/037abandon.cc @@ -36,27 +36,17 @@ void abandon(int address, const type_tree* payload_type, int payload_size) { element.type = copy_array_element(payload_type); int array_length = get_or_insert(Memory, address+/*skip refcount*/1); assert(element.type->name != "array"); - if (is_mu_address(element)) { - for (element.set_value(address+/*skip refcount*/1+/*skip length*/1); element.value < address+/*skip refcount*/1+/*skip length*/1+array_length; ++element.value) - update_refcounts(element, 0); - } - else if (is_mu_container(element) || is_mu_exclusive_container(element)) { - int element_size = size_of(element); - vector zeros; - zeros.resize(element_size); - for (int i = 0; i < array_length; ++i) { - element.set_value(address + /*skip refcount*/1 + /*skip array length*/1 + i*element_size); - update_container_refcounts(element, zeros); - } + int element_size = size_of(element); + for (int i = 0; i < array_length; ++i) { + element.set_value(address + /*skip refcount*/1 + /*skip array length*/1 + i*element_size); + decrement_any_refcounts(element); } } else if (is_mu_container(payload_type) || is_mu_exclusive_container(payload_type)) { reagent tmp; - tmp.set_value(address + /*skip refcount*/1); tmp.type = new type_tree(*payload_type); - vector zeros; - zeros.resize(size_of(payload_type)); - update_container_refcounts(tmp, zeros); + tmp.set_value(address + /*skip refcount*/1); + decrement_any_refcounts(tmp); } // clear memory for (int curr = address; curr < address+payload_size; ++curr) -- cgit 1.4.1-2-gfad0