Skip to content

Commit 58e0f10

Browse files
committed
Restore namespace after symbolic execution
This was already fixed in d475abc, but 685937a introduced additional returns. Now use an approach that will always work, even when returning via exceptions being thrown.
1 parent 3120f0f commit 58e0f10

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--symex-coverage-report - --paths lifo
4+
<line branch="false" hits="1" number="12"/>
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring

src/goto-symex/symex_main.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,31 @@ void goto_symext::symex_with_state(
242242
const get_goto_functiont &get_goto_function,
243243
symbol_tablet &new_symbol_table)
244244
{
245+
struct reset_namespacet
246+
{
247+
explicit reset_namespacet(namespacet &ns) : ns(ns)
248+
{
249+
}
250+
251+
~reset_namespacet()
252+
{
253+
const symbol_tablet &st = ns.get_symbol_table();
254+
ns = namespacet(st);
255+
}
256+
257+
namespacet &ns;
258+
};
259+
245260
// We'll be using ns during symbolic execution and it needs to know
246261
// about the names minted in `state`, so make it point both to
247262
// `state`'s symbol table and the symbol table of the original
248263
// goto-program.
249264
ns = namespacet(outer_symbol_table, state.symbol_table);
250265

266+
// whichever way we exit this method, reset the namespace back to a sane state
267+
// as state.symbol_table might go out of scope
268+
reset_namespacet reset_ns(ns);
269+
251270
PRECONDITION(state.top().end_of_function->is_end_function());
252271

253272
symex_threaded_step(state, get_goto_function);
@@ -267,9 +286,6 @@ void goto_symext::symex_with_state(
267286
// execution, so return the names generated through symbolic execution
268287
// through `new_symbol_table`.
269288
new_symbol_table = state.symbol_table;
270-
// reset the namespace back to a sane state as state.symbol_table might go out
271-
// of scope
272-
ns = namespacet(outer_symbol_table);
273289
}
274290

275291
void goto_symext::resume_symex_from_saved_state(

0 commit comments

Comments
 (0)