Skip to content

Commit c463693

Browse files
committed
goto-symex: move level1 map to goto_statet
A local variable may have left the scope on a branch, but may still exist via another path. Upon merging paths we must not lose such objects. Fixes: #8437
1 parent 4ae54e6 commit c463693

File tree

6 files changed

+33
-2
lines changed

6 files changed

+33
-2
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
int main()
2+
{
3+
int jumpguard;
4+
jumpguard = jumpguard | 1;
5+
label_1:
6+
while(1)
7+
{
8+
int canary = 1;
9+
if(jumpguard == 0)
10+
{
11+
goto label_1;
12+
}
13+
__CPROVER_assert(canary, "should pass");
14+
break;
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/goto-symex/goto_state.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class goto_statet
3838
symex_level2t level2;
3939

4040
public:
41+
symex_level1t level1;
42+
4143
/// This is used for eliminating repeated complicated dereferences.
4244
/// \see goto_symext::dereference_rec
4345
sharing_mapt<exprt, symbol_exprt, false, irep_hash> dereference_cache;

src/goto-symex/goto_symex_state.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class goto_symex_statet final : public goto_statet
7070
guard_managert &guard_manager;
7171
symex_target_equationt *symex_target;
7272

73-
symex_level1t level1;
74-
7573
/// Rewrites symbol expressions in \ref exprt, applying a suffix to each
7674
/// symbol reflecting its most recent version, which differs depending on
7775
/// which level you requested. Each level also updates its predecessors, so
@@ -188,6 +186,7 @@ class goto_symex_statet final : public goto_statet
188186
irep_idt function_id;
189187
guardt guard;
190188
call_stackt call_stack;
189+
symex_level1t level1;
191190
std::map<irep_idt, unsigned> function_frame;
192191
unsigned atomic_section_id = 0;
193192
explicit threadt(guard_managert &guard_manager)

src/goto-symex/symex_main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ switch_to_thread(goto_symex_statet &state, const unsigned int thread_nb)
291291
state.source.pc = state.threads[thread_nb].pc;
292292
state.source.function_id = state.threads[thread_nb].function_id;
293293

294+
state.level1.restore_from(state.threads[thread_nb].level1);
295+
294296
state.guard = state.threads[thread_nb].guard;
295297
// A thread's initial state is certainly reachable:
296298
state.reachable = true;

src/goto-symex/symex_start_thread.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ void goto_symext::symex_start_thread(statet &state)
117117
}
118118
}
119119

120+
// retain the current set of objects so as to restore when symbolically
121+
// executing the thread
122+
new_thread.level1 = state.level1;
123+
120124
// initialize all variables marked thread-local
121125
const symbol_tablet &symbol_table=ns.get_symbol_table();
122126

0 commit comments

Comments
 (0)