Skip to content

Commit 7f2b979

Browse files
committed
Re-use symex state initialisation helper in loop acceleration
The local attempt of initialisation did not keep up with changes and assumptions made by goto_symext, resulting in segmentation faults when trying to use this code.
1 parent 1b6d8d9 commit 7f2b979

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

src/goto-instrument/accelerate/scratch_program.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ bool scratch_programt::check_sat(bool do_slice, guard_managert &guard_manager)
3636
output(ns, "scratch", std::cout);
3737
#endif
3838

39-
symex_state = util_make_unique<goto_symex_statet>(
40-
symex_targett::sourcet(goto_functionst::entry_point(), *this),
41-
DEFAULT_MAX_FIELD_SENSITIVITY_ARRAY_SIZE,
42-
guard_manager,
43-
[this](const irep_idt &id) {
44-
return path_storage.get_unique_l2_index(id);
45-
});
46-
47-
symex.symex_with_state(
48-
*symex_state,
49-
[this](const irep_idt &key) -> const goto_functionst::goto_functiont & {
39+
goto_functiont this_goto_function;
40+
this_goto_function.body.copy_from(*this);
41+
auto get_goto_function =
42+
[this, &this_goto_function](
43+
const irep_idt &key) -> const goto_functionst::goto_functiont & {
44+
if(key == goto_functionst::entry_point())
45+
return this_goto_function;
46+
else
5047
return functions.function_map.at(key);
51-
},
52-
symex_symbol_table);
48+
};
49+
50+
symex_state = symex.initialize_entry_point_state(get_goto_function);
51+
52+
symex.symex_with_state(*symex_state, get_goto_function, symex_symbol_table);
5353

5454
if(do_slice)
5555
{

src/goto-instrument/accelerate/scratch_program.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ Author: Matt Lewis
3333

3434
#include "path.h"
3535

36+
// Wrapper around goto_symext to make initialize_entry_point_state available.
37+
struct scratch_program_symext : public goto_symext
38+
{
39+
scratch_program_symext(
40+
message_handlert &mh,
41+
const symbol_tablet &outer_symbol_table,
42+
symex_target_equationt &_target,
43+
const optionst &options,
44+
path_storaget &path_storage,
45+
guard_managert &guard_manager)
46+
: goto_symext(
47+
mh,
48+
outer_symbol_table,
49+
_target,
50+
options,
51+
path_storage,
52+
guard_manager)
53+
{
54+
}
55+
56+
std::unique_ptr<statet>
57+
initialize_entry_point_state(const get_goto_functiont &get_goto_function)
58+
{
59+
return goto_symext::initialize_entry_point_state(get_goto_function);
60+
}
61+
};
62+
3663
class scratch_programt:public goto_programt
3764
{
3865
public:
@@ -85,7 +112,7 @@ class scratch_programt:public goto_programt
85112
symex_target_equationt equation;
86113
path_fifot path_storage;
87114
optionst options;
88-
goto_symext symex;
115+
scratch_program_symext symex;
89116

90117
std::unique_ptr<propt> satcheck;
91118
bv_pointerst satchecker;

0 commit comments

Comments
 (0)