Skip to content

Commit f170ba1

Browse files
committed
Unwindset parsing: check loop identifiers
We silently accepted unwindset specifications that included non-existent loop identifiers.
1 parent c05708c commit f170ba1

16 files changed

+131
-16
lines changed

regression/cbmc/unwindset1/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
int main()
2+
{
3+
int x;
4+
for_loop:
5+
for(int i = 0; i < x; ++i)
6+
--x;
7+
for(int j = 0; j < 5; ++j)
8+
++x;
9+
__CPROVER_assert(0, "can be reached");
10+
}

regression/cbmc/unwindset1/test.desc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--unwindset main.0:2,main.2:2
4+
^Invalid User Input$
5+
^Option: unwindset$
6+
^Reason: invalid loop identifier main\.2$
7+
^EXIT=1$
8+
^SIGNAL=0$
9+
--
10+
^warning: ignoring

src/goto-checker/multi_path_symex_only_checker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
2828
goto_model(goto_model),
2929
ns(goto_model.get_symbol_table(), symex_symbol_table),
3030
equation(ui_message_handler),
31+
unwindset(goto_model),
3132
symex(
3233
ui_message_handler,
3334
goto_model.get_symbol_table(),
3435
equation,
3536
options,
3637
path_storage,
37-
guard_manager)
38+
guard_manager,
39+
unwindset)
3840
{
3941
setup_symex(symex, ns, options, ui_message_handler);
4042
}

src/goto-checker/multi_path_symex_only_checker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Author: Daniel Kroening, Peter Schrammel
1616

1717
#include <goto-symex/path_storage.h>
1818

19+
#include <goto-instrument/unwindset.h>
20+
1921
#include "symex_bmc.h"
2022

2123
class multi_path_symex_only_checkert : public incremental_goto_checkert
@@ -35,6 +37,7 @@ class multi_path_symex_only_checkert : public incremental_goto_checkert
3537
symex_target_equationt equation;
3638
guard_managert guard_manager;
3739
path_fifot path_storage; // should go away
40+
unwindsett unwindset;
3841
symex_bmct symex;
3942

4043
/// Generates the equation by running goto-symex

src/goto-checker/single_loop_incremental_symex_checker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ single_loop_incremental_symex_checkert::single_loop_incremental_symex_checkert(
3030
goto_model(goto_model),
3131
ns(goto_model.get_symbol_table(), symex_symbol_table),
3232
equation(ui_message_handler),
33+
unwindset(goto_model),
3334
symex(
3435
ui_message_handler,
3536
goto_model.get_symbol_table(),
3637
equation,
3738
options,
3839
path_storage,
3940
guard_manager,
41+
unwindset,
4042
ui_message_handler.get_ui()),
4143
property_decider(options, ui_message_handler, equation, ns)
4244
{

src/goto-checker/single_loop_incremental_symex_checker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Author: Daniel Kroening, Peter Schrammel
1616

1717
#include <goto-symex/path_storage.h>
1818

19+
#include <goto-instrument/unwindset.h>
20+
1921
#include "goto_symex_property_decider.h"
2022
#include "goto_trace_provider.h"
2123
#include "incremental_goto_checker.h"
@@ -57,6 +59,7 @@ class single_loop_incremental_symex_checkert : public incremental_goto_checkert,
5759
symex_target_equationt equation;
5860
path_fifot path_storage; // should go away
5961
guard_managert guard_manager;
62+
unwindsett unwindset;
6063
symex_bmc_incremental_one_loopt symex;
6164
bool initial_equation_generated = false;
6265
bool full_equation_generated = false;

src/goto-checker/single_path_symex_only_checker.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ single_path_symex_only_checkert::single_path_symex_only_checkert(
3030
goto_model(goto_model),
3131
ns(goto_model.get_symbol_table(), symex_symbol_table),
3232
worklist(get_path_strategy(options.get_option("exploration-strategy"))),
33-
symex_runtime(0)
33+
symex_runtime(0),
34+
unwindset(goto_model)
3435
{
3536
}
3637

@@ -70,7 +71,8 @@ void single_path_symex_only_checkert::initialize_worklist()
7071
equation,
7172
options,
7273
*worklist,
73-
guard_manager);
74+
guard_manager,
75+
unwindset);
7476
setup_symex(symex);
7577

7678
symex.initialize_path_storage_from_entry_point_of(
@@ -95,7 +97,8 @@ bool single_path_symex_only_checkert::resume_path(path_storaget::patht &path)
9597
path.equation,
9698
options,
9799
*worklist,
98-
guard_manager);
100+
guard_manager,
101+
unwindset);
99102
setup_symex(symex);
100103

101104
symex.resume_symex_from_saved_state(

src/goto-checker/single_path_symex_only_checker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Author: Daniel Kroening, Peter Schrammel
1616

1717
#include <goto-symex/path_storage.h>
1818

19+
#include <goto-instrument/unwindset.h>
20+
1921
#include <chrono>
2022

2123
class symex_bmct;
@@ -40,6 +42,7 @@ class single_path_symex_only_checkert : public incremental_goto_checkert
4042
guard_managert guard_manager;
4143
std::unique_ptr<path_storaget> worklist;
4244
std::chrono::duration<double> symex_runtime;
45+
unwindsett unwindset;
4346

4447
void equation_output(
4548
const symex_bmct &symex,

src/goto-checker/symex_bmc.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/simplify_expr.h>
1717
#include <util/source_location.h>
1818

19+
#include <goto-instrument/unwindset.h>
20+
1921
symex_bmct::symex_bmct(
2022
message_handlert &mh,
2123
const symbol_tablet &outer_symbol_table,
2224
symex_target_equationt &_target,
2325
const optionst &options,
2426
path_storaget &path_storage,
25-
guard_managert &guard_manager)
27+
guard_managert &guard_manager,
28+
unwindsett &unwindset)
2629
: goto_symext(
2730
mh,
2831
outer_symbol_table,
@@ -33,6 +36,7 @@ symex_bmct::symex_bmct(
3336
record_coverage(!options.get_option("symex-coverage-report").empty()),
3437
havoc_bodyless_functions(
3538
options.get_bool_option("havoc-undefined-functions")),
39+
unwindset(unwindset),
3640
symex_coverage(ns)
3741
{
3842
}

src/goto-checker/symex_bmc.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Author: Daniel Kroening, [email protected]
1616

1717
#include <goto-symex/goto_symex.h>
1818

19-
#include <goto-instrument/unwindset.h>
20-
2119
#include "symex_coverage.h"
2220

21+
class unwindsett;
22+
2323
class symex_bmct : public goto_symext
2424
{
2525
public:
@@ -29,7 +29,8 @@ class symex_bmct : public goto_symext
2929
symex_target_equationt &_target,
3030
const optionst &options,
3131
path_storaget &path_storage,
32-
guard_managert &guard_manager);
32+
guard_managert &guard_manager,
33+
unwindsett &unwindset);
3334

3435
// To show progress
3536
source_locationt last_source_location;
@@ -81,7 +82,7 @@ class symex_bmct : public goto_symext
8182
const bool record_coverage;
8283
const bool havoc_bodyless_functions;
8384

84-
unwindsett unwindset;
85+
unwindsett &unwindset;
8586

8687
protected:
8788
/// Callbacks that may provide an unwind/do-not-unwind decision for a loop

0 commit comments

Comments
 (0)