Skip to content

Commit 44a35ac

Browse files
author
Daniel Kroening
committed
ensure goto_symex_statet::source is always set
sourcet contains an interator, and the interface explicitly allows it to be uninitialised. However, most parts of the code base access source.pc without checking.
1 parent d87f247 commit 44a35ac

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ Author: Daniel Kroening, [email protected]
2727

2828
static void get_l1_name(exprt &expr);
2929

30-
goto_symex_statet::goto_symex_statet()
30+
goto_symex_statet::goto_symex_statet(const symex_targett::sourcet &_source)
3131
: depth(0),
32+
source(_source),
3233
symex_target(nullptr),
3334
atomic_section_id(0),
3435
total_vccs(0),
@@ -767,11 +768,8 @@ void goto_symex_statet::print_backtrace(std::ostream &out) const
767768
++stackit)
768769
{
769770
const auto &frame = *stackit;
770-
if(frame.calling_location.is_set)
771-
{
772-
out << frame.calling_location.pc->function << " "
773-
<< frame.calling_location.pc->location_number << "\n";
774-
}
771+
out << frame.calling_location.pc->function << " "
772+
<< frame.calling_location.pc->location_number << "\n";
775773
}
776774
}
777775

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Author: Daniel Kroening, [email protected]
3434
class goto_symex_statet final
3535
{
3636
public:
37-
goto_symex_statet();
37+
explicit goto_symex_statet(const symex_targett::sourcet &);
3838
~goto_symex_statet();
3939

4040
/// \brief Fake "copy constructor" that initializes the `symex_target` member

src/goto-symex/symex_function_call.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ void goto_symext::symex_function_call_code(
321321
frame.loop_iterations[identifier].is_recursion=true;
322322
frame.loop_iterations[identifier].count++;
323323

324-
state.source.is_set=true;
325324
state.source.function = identifier;
326325
symex_transition(state, goto_function.body.instructions.begin(), false);
327326
}

src/goto-symex/symex_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ void goto_symext::symex_from_entry_point_of(
306306
throw unsupported_operation_exceptiont("the program has no entry point");
307307
}
308308

309-
statet state;
309+
statet state(symex_targett::sourcet(
310+
goto_functionst::entry_point(), start_function->body));
310311

311312
state.run_validation_checks = symex_config.run_validation_checks;
312313

src/goto-symex/symex_target_equation.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -694,15 +694,12 @@ void symex_target_equationt::SSA_stept::output(
694694
const namespacet &ns,
695695
std::ostream &out) const
696696
{
697-
if(source.is_set)
698-
{
699-
out << "Thread " << source.thread_nr;
697+
out << "Thread " << source.thread_nr;
700698

701-
if(source.pc->source_location.is_not_nil())
702-
out << " " << source.pc->source_location << '\n';
703-
else
704-
out << '\n';
705-
}
699+
if(source.pc->source_location.is_not_nil())
700+
out << " " << source.pc->source_location << '\n';
701+
else
702+
out << '\n';
706703

707704
switch(type)
708705
{
@@ -795,15 +792,12 @@ void symex_target_equationt::SSA_stept::output(
795792

796793
void symex_target_equationt::SSA_stept::output(std::ostream &out) const
797794
{
798-
if(source.is_set)
799-
{
800-
out << "Thread " << source.thread_nr;
795+
out << "Thread " << source.thread_nr;
801796

802-
if(source.pc->source_location.is_not_nil())
803-
out << " " << source.pc->source_location << '\n';
804-
else
805-
out << '\n';
806-
}
797+
if(source.pc->source_location.is_not_nil())
798+
out << " " << source.pc->source_location << '\n';
799+
else
800+
out << '\n';
807801

808802
switch(type)
809803
{

0 commit comments

Comments
 (0)