diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-20 17:41:56 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-20 17:41:56 -0700 |
commit | 59d827a27472d90cb7d22be8ef6a3b161fb1c0dc (patch) | |
tree | 90f780987b0d568ca6c58ff3856d9da98ed32052 | |
parent | 0e0982df964311e040862f0381bce47cd21ae9d5 (diff) | |
download | mu-59d827a27472d90cb7d22be8ef6a3b161fb1c0dc.tar.gz |
3529
Bugfix: refcounts were getting updated for the wrong ingredients in 'call' instructions.
-rw-r--r-- | 071recipe.cc | 4 | ||||
-rw-r--r-- | 072scheduler.cc | 17 |
2 files changed, 20 insertions, 1 deletions
diff --git a/071recipe.cc b/071recipe.cc index 4a8caefd..9135feda 100644 --- a/071recipe.cc +++ b/071recipe.cc @@ -114,7 +114,9 @@ case CALL: { raise << maybe(current_recipe_name()) << "tried to call empty recipe in '" << to_string(current_instruction()) << "'" << end(); break; } - const instruction& call_instruction = current_instruction(); + instruction/*copy*/ call_instruction = current_instruction(); + call_instruction.operation = ingredients.at(0).at(0); + call_instruction.ingredients.erase(call_instruction.ingredients.begin()); Current_routine->calls.push_front(call(ingredients.at(0).at(0))); ingredients.erase(ingredients.begin()); // drop the callee finish_call_housekeeping(call_instruction, ingredients); diff --git a/072scheduler.cc b/072scheduler.cc index 593dac9c..38f62fa0 100644 --- a/072scheduler.cc +++ b/072scheduler.cc @@ -279,6 +279,23 @@ if (inst.operation == NEXT_INGREDIENT || inst.operation == NEXT_INGREDIENT_WITHO return false; } +// ensure this works with indirect calls using 'call' as well +:(scenario start_running_immediately_updates_refcounts_of_ingredients_of_indirect_calls) +% Scheduling_interval = 1; +def main [ + local-scope + n:&:num <- new number:type + *n <- copy 34 + call f1, n + 1:num/raw <- copy *n +] +def f1 n:&:num [ + local-scope + load-ingredients +] +# check that n wasn't reclaimed when f1 returned ++mem: storing 34 in location 1 + :(scenario next_ingredient_never_leaks_refcounts) def create-space n:&:num -> default-space:space [ default-space <- new location:type, 2 |