diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-08-17 12:14:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-08-17 12:14:09 -0700 |
commit | 75ab8732386096a77113514f767e134e42a5435f (patch) | |
tree | a3fd2a9a578b8fd3965b8c7f6905600fbbcfcb58 /037abandon.cc | |
parent | ed8e4c17417828528fbb2350b19f24d73c989fc9 (diff) | |
download | mu-75ab8732386096a77113514f767e134e42a5435f.tar.gz |
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.
Diffstat (limited to '037abandon.cc')
-rw-r--r-- | 037abandon.cc | 22 |
1 files changed, 6 insertions, 16 deletions
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<double> 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<double> 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) |