From d82c16098e4f7454b79ee4cad6393949d6f32b18 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 24 Jun 2018 09:38:44 -0700 Subject: 4268 - add a simple validation of the alloc-id Tautological for now since all alloc-ids are zero. --- 035lookup.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to '035lookup.cc') diff --git a/035lookup.cc b/035lookup.cc index ebed6b4d..3b9ae6a2 100644 --- a/035lookup.cc +++ b/035lookup.cc @@ -89,6 +89,7 @@ void lookup_memory_core(reagent& x, bool check_for_null) { double address = x.value + /*skip alloc id in address*/1; double new_value = get_or_insert(Memory, address); trace("mem") << "location " << address << " contains " << no_scientific(new_value) << end(); + // check for null if (check_for_null && new_value == 0) { if (Current_routine) { raise << maybe(current_recipe_name()) << "tried to lookup 0 in '" << to_original_string(current_instruction()) << "'\n" << end(); @@ -98,6 +99,14 @@ void lookup_memory_core(reagent& x, bool check_for_null) { raise << "tried to lookup 0\n" << end(); } } + // validate alloc-id + double alloc_id_in_address = get_or_insert(Memory, x.value); + double alloc_id_in_payload = get_or_insert(Memory, new_value); + if (alloc_id_in_address != alloc_id_in_payload) { + raise << maybe(current_recipe_name()) << "address is already abandoned in '" << to_original_string(current_instruction()) << "'\n" << end(); + dump_callstack(); + } + // all well; complete the lookup x.set_value(new_value+/*skip alloc id in payload*/1); drop_from_type(x, "address"); drop_one_lookup(x); -- cgit 1.4.1-2-gfad0