Skip to content

Commit 96284f4

Browse files
smowtonJohnDumbell
authored andcommitted
Symex: protect level2
We really should protect the level 2 name map to prevent "allocating" a new generation by just making one up in the local name map, cf. applying for one properly using increase_generation.
1 parent f778fda commit 96284f4

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

src/goto-symex/auto_objects.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ void goto_symext::trigger_auto_object(const exprt &expr, statet &state)
9191
if(has_prefix(id2string(symbol.base_name), "auto_object"))
9292
{
9393
// done already?
94-
if(state.level2.current_names.find(ssa_expr.get_identifier())==
95-
state.level2.current_names.end())
94+
if(
95+
state.get_level2().current_names.find(ssa_expr.get_identifier()) ==
96+
state.get_level2().current_names.end())
9697
{
9798
initialize_auto_object(expr, state);
9899
}

src/goto-symex/goto_state.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@ class goto_statet
2828
/// Distance from entry
2929
unsigned depth = 0;
3030

31+
protected:
3132
symex_level2t level2;
3233

34+
public:
35+
const symex_level2t &get_level2() const
36+
{
37+
return level2;
38+
}
39+
3340
/// Uses level 1 names, and is used to do dereferencing
3441
value_sett value_set;
3542

src/goto-symex/goto_symex_state.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ class goto_symex_statet final : public goto_statet
214214
/// isn't an expression keyed by it.
215215
void increase_generation_if_exists(const irep_idt identifier);
216216

217+
/// Drops an L1 name from the local L2 map
218+
void drop_l1_name(symex_renaming_levelt::current_namest::const_iterator it)
219+
{
220+
level2.current_names.erase(it);
221+
}
222+
217223
private:
218224
std::function<std::size_t(const irep_idt &)> fresh_l2_name_provider;
219225

src/goto-symex/symex_atomic_section.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void goto_symext::symex_atomic_end(statet &state)
7070
for(const auto &pair : state.written_in_atomic_section)
7171
{
7272
ssa_exprt w = pair.first;
73-
w.set_level_2(state.level2.current_count(w.get_identifier()));
73+
w.set_level_2(state.get_level2().current_count(w.get_identifier()));
7474

7575
// guard is the disjunction over writes
7676
PRECONDITION(!pair.second.empty());

src/goto-symex/symex_function_call.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ static void pop_frame(goto_symext::statet &state)
349349
state.level1.restore_from(frame.old_level1);
350350

351351
// clear function-locals from L2 renaming
352-
for(auto c_it = state.level2.current_names.begin();
353-
c_it != state.level2.current_names.end();) // no ++c_it
352+
for(auto c_it = state.get_level2().current_names.begin();
353+
c_it != state.get_level2().current_names.end();) // no ++c_it
354354
{
355355
const irep_idt l1_o_id=c_it->second.first.get_l1_object_identifier();
356356
// could use iteration over local_objects as l1_o_id is prefix
@@ -364,7 +364,7 @@ static void pop_frame(goto_symext::statet &state)
364364
}
365365
auto cur = c_it;
366366
++c_it;
367-
state.level2.current_names.erase(cur);
367+
state.drop_l1_name(cur);
368368
}
369369
}
370370

src/goto-symex/symex_goto.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,17 @@ void goto_symext::phi_function(
521521
statet &dest_state)
522522
{
523523
if(
524-
goto_state.level2.current_names.empty() &&
525-
dest_state.level2.current_names.empty())
524+
goto_state.get_level2().current_names.empty() &&
525+
dest_state.get_level2().current_names.empty())
526526
return;
527527

528528
guardt diff_guard = goto_state.guard;
529529
// this gets the diff between the guards
530530
diff_guard -= dest_state.guard;
531531

532532
for_each2(
533-
goto_state.level2.current_names,
534-
dest_state.level2.current_names,
533+
goto_state.get_level2().current_names,
534+
dest_state.get_level2().current_names,
535535
[&](const ssa_exprt &ssa, unsigned goto_count, unsigned dest_count) {
536536
merge_names(
537537
goto_state,

src/goto-symex/symex_start_thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void goto_symext::symex_start_thread(statet &state)
5252
// create a copy of the local variables for the new thread
5353
framet &frame = state.call_stack().top();
5454

55-
for(auto c_it = state.level2.current_names.begin();
56-
c_it != state.level2.current_names.end();
55+
for(auto c_it = state.get_level2().current_names.begin();
56+
c_it != state.get_level2().current_names.end();
5757
++c_it)
5858
{
5959
const irep_idt l1_o_id=c_it->second.first.get_l1_object_identifier();

0 commit comments

Comments
 (0)