Skip to content

Commit a61e04a

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 85d61b5 commit a61e04a

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-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: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,32 @@ 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)
248+
: ns(ns)
249+
{
250+
}
251+
252+
~reset_namespacet()
253+
{
254+
const symbol_tablet &st = ns.get_symbol_table();
255+
ns = namespacet(st);
256+
}
257+
258+
namespacet &ns;
259+
};
260+
245261
// We'll be using ns during symbolic execution and it needs to know
246262
// about the names minted in `state`, so make it point both to
247263
// `state`'s symbol table and the symbol table of the original
248264
// goto-program.
249265
ns = namespacet(outer_symbol_table, state.symbol_table);
250266

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

253273
symex_threaded_step(state, get_goto_function);
@@ -267,9 +287,6 @@ void goto_symext::symex_with_state(
267287
// execution, so return the names generated through symbolic execution
268288
// through `new_symbol_table`.
269289
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);
273290
}
274291

275292
void goto_symext::resume_symex_from_saved_state(

0 commit comments

Comments
 (0)