Skip to content

Commit b0806f2

Browse files
Merge pull request #3795 from peterschrammel/multi-path-symex-checker
Multi-path symex checker [blocks: 3796]
2 parents 686a082 + 37ae8b1 commit b0806f2

31 files changed

+996
-172
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*******************************************************************\
2+
3+
Module: Goto Checker using Bounded Model Checking for Java
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Goto Checker using Bounded Model Checking for Java
11+
12+
#ifndef CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_CHECKER_H
13+
#define CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_CHECKER_H
14+
15+
#include <goto-checker/multi_path_symex_checker.h>
16+
17+
#include "java_bmc_util.h"
18+
19+
class java_multi_path_symex_checkert : public multi_path_symex_checkert
20+
{
21+
public:
22+
java_multi_path_symex_checkert(
23+
const optionst &options,
24+
ui_message_handlert &ui_message_handler,
25+
abstract_goto_modelt &goto_model)
26+
: multi_path_symex_checkert(options, ui_message_handler, goto_model)
27+
{
28+
java_setup_symex(options, goto_model, symex);
29+
}
30+
};
31+
32+
#endif // CPROVER_JAVA_BYTECODE_JAVA_MULTI_PATH_SYMEX_CHECKER_H

jbmc/src/jbmc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ OBJ += ../$(CPROVER_DIR)/src/ansi-c/ansi-c$(LIBEXT) \
4141
../$(CPROVER_DIR)/src/cbmc/all_properties$(OBJEXT) \
4242
../$(CPROVER_DIR)/src/cbmc/bmc$(OBJEXT) \
4343
../$(CPROVER_DIR)/src/cbmc/bmc_cover$(OBJEXT) \
44-
../$(CPROVER_DIR)/src/cbmc/counterexample_beautification$(OBJEXT) \
4544
../$(CPROVER_DIR)/src/cbmc/fault_localization$(OBJEXT) \
4645
# Empty last line
4746

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Author: Daniel Kroening, [email protected]
2828
#include <ansi-c/ansi_c_language.h>
2929

3030
#include <goto-checker/all_properties_verifier.h>
31+
#include <goto-checker/all_properties_verifier_with_trace_storage.h>
3132

3233
#include <goto-programs/adjust_float_expressions.h>
3334
#include <goto-programs/lazy_goto_model.h>
@@ -61,6 +62,7 @@ Author: Daniel Kroening, [email protected]
6162
#include <java_bytecode/convert_java_nondet.h>
6263
#include <java_bytecode/java_bytecode_language.h>
6364
#include <java_bytecode/java_enum_static_init_unwind_handler.h>
65+
#include <java_bytecode/java_multi_path_symex_checker.h>
6466
#include <java_bytecode/java_multi_path_symex_only_checker.h>
6567
#include <java_bytecode/remove_exceptions.h>
6668
#include <java_bytecode/remove_instanceof.h>
@@ -564,13 +566,30 @@ int jbmc_parse_optionst::doit()
564566
}
565567
}
566568

567-
// The `configure_bmc` callback passed will enable enum-unwind-static if
568-
// applicable.
569-
return bmct::do_language_agnostic_bmc(
570-
options,
571-
goto_model,
572-
ui_message_handler,
573-
configure_bmc);
569+
std::unique_ptr<goto_verifiert> verifier = nullptr;
570+
571+
if(!options.get_bool_option("paths") && !options.is_set("cover"))
572+
{
573+
if(!options.get_bool_option("stop-on-fail"))
574+
{
575+
verifier = util_make_unique<all_properties_verifier_with_trace_storaget<
576+
java_multi_path_symex_checkert>>(
577+
options, ui_message_handler, goto_model);
578+
}
579+
}
580+
581+
// fall back until everything has been ported to goto-checker
582+
if(verifier == nullptr)
583+
{
584+
// The `configure_bmc` callback passed will enable enum-unwind-static if
585+
// applicable.
586+
return bmct::do_language_agnostic_bmc(
587+
options, goto_model, ui_message_handler, configure_bmc);
588+
}
589+
590+
resultt result = (*verifier)();
591+
verifier->report();
592+
return result_to_exit_code(result);
574593
}
575594
else
576595
{

jbmc/unit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ BMC_DEPS =$(CPROVER_DIR)/src/cbmc/all_properties$(OBJEXT) \
8686
$(CPROVER_DIR)/src/cbmc/bmc$(OBJEXT) \
8787
$(CPROVER_DIR)/src/cbmc/bmc_cover$(OBJEXT) \
8888
$(CPROVER_DIR)/src/cbmc/cbmc_languages$(OBJEXT) \
89-
$(CPROVER_DIR)/src/cbmc/counterexample_beautification$(OBJEXT) \
9089
$(CPROVER_DIR)/src/cbmc/fault_localization$(OBJEXT) \
9190
$(CPROVER_DIR)/src/cbmc/xml_interface$(OBJEXT) \
9291
$(CPROVER_DIR)/src/jsil/expr2jsil$(OBJEXT) \
@@ -131,6 +130,7 @@ CPROVER_LIBS =../src/java_bytecode/java_bytecode$(LIBEXT) \
131130
$(CPROVER_DIR)/src/pointer-analysis/pointer-analysis$(LIBEXT) \
132131
$(CPROVER_DIR)/src/langapi/langapi$(LIBEXT) \
133132
$(CPROVER_DIR)/src/xmllang/xmllang$(LIBEXT) \
133+
$(CPROVER_DIR)/src/assembler/assembler$(LIBEXT) \
134134
$(CPROVER_DIR)/src/analyses/analyses$(LIBEXT) \
135135
$(CPROVER_DIR)/src/solvers/solvers$(LIBEXT) \
136136
$(BMC_DEPS) \

regression/cbmc/Multi_Dimensional_Array6/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ main.c
33
--unwind 3 --no-unwinding-assertions
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[main\.assertion\.1\] .* : SUCCESS$
7-
^\[main\.assertion\.2\] .* : FAILURE$
6+
^\[main\.assertion\.1\] .*: SUCCESS$
7+
^\[main\.assertion\.2\] .*: FAILURE$
88
^\*\* 1 of 2 failed
99
--
1010
^warning: ignoring

regression/cbmc/goto4/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=10$
55
^SIGNAL=0$
66
^\[.*] line 5 assertion g == 0: SUCCESS$
7-
^\[.*] unwinding assertion loop 0: FAILURE$
7+
^\[.*] line 14 unwinding assertion loop 0: FAILURE$
88
--
99
^warning: ignoring

regression/contracts/function_check_04/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CORE
22
main.c
33
--apply-code-contracts
44
^\[main.assertion.1\] .* assertion x == 0: SUCCESS$
5-
^\[foo.1\] line 9 : FAILURE$
5+
^\[foo.1\] line 9 .*: FAILURE$
66
^VERIFICATION FAILED$
77
--
88
--

src/cbmc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ SRC = all_properties.cpp \
44
cbmc_languages.cpp \
55
cbmc_main.cpp \
66
cbmc_parse_options.cpp \
7-
counterexample_beautification.cpp \
87
fault_localization.cpp \
98
xml_interface.cpp \
109
# Empty last line

src/cbmc/bmc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Author: Daniel Kroening, [email protected]
2525
#include <linking/static_lifetime_init.h>
2626

2727
#include <goto-checker/bmc_util.h>
28+
#include <goto-checker/counterexample_beautification.h>
2829
#include <goto-checker/report_util.h>
2930
#include <goto-checker/solver_factory.h>
3031

31-
#include "counterexample_beautification.h"
3232
#include "fault_localization.h"
3333

3434
/// Hook used by CEGIS to selectively freeze variables

src/cbmc/cbmc_parse_options.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Author: Daniel Kroening, [email protected]
3333
#include <cpp/cprover_library.h>
3434

3535
#include <goto-checker/all_properties_verifier.h>
36+
#include <goto-checker/all_properties_verifier_with_trace_storage.h>
3637
#include <goto-checker/bmc_util.h>
38+
#include <goto-checker/multi_path_symex_checker.h>
3739
#include <goto-checker/multi_path_symex_only_checker.h>
3840
#include <goto-checker/properties.h>
3941

@@ -562,8 +564,28 @@ int cbmc_parse_optionst::doit()
562564
}
563565
}
564566

565-
return bmct::do_language_agnostic_bmc(
566-
options, goto_model, ui_message_handler);
567+
std::unique_ptr<goto_verifiert> verifier = nullptr;
568+
569+
if(!options.get_bool_option("paths") && !options.is_set("cover"))
570+
{
571+
if(!options.get_bool_option("stop-on-fail"))
572+
{
573+
verifier = util_make_unique<
574+
all_properties_verifier_with_trace_storaget<multi_path_symex_checkert>>(
575+
options, ui_message_handler, goto_model);
576+
}
577+
}
578+
579+
// fall back until everything has been ported to goto-checker
580+
if(verifier == nullptr)
581+
{
582+
return bmct::do_language_agnostic_bmc(
583+
options, goto_model, ui_message_handler);
584+
}
585+
586+
resultt result = (*verifier)();
587+
verifier->report();
588+
return result_to_exit_code(result);
567589
}
568590

569591
bool cbmc_parse_optionst::set_properties()

src/cbmc/fault_localization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ Author: Peter Schrammel
2424
#include <solvers/prop/literal_expr.h>
2525

2626
#include <goto-symex/build_goto_trace.h>
27+
2728
#include <goto-programs/xml_goto_trace.h>
2829

2930
#include <goto-checker/bmc_util.h>
31+
#include <goto-checker/counterexample_beautification.h>
3032
#include <goto-checker/report_util.h>
3133

32-
#include "counterexample_beautification.h"
3334

3435
void fault_localizationt::freeze_guards()
3536
{

src/goto-checker/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
SRC = bmc_util.cpp \
2+
counterexample_beautification.cpp \
23
incremental_goto_checker.cpp \
4+
goto_trace_storage.cpp \
35
goto_verifier.cpp \
6+
multi_path_symex_checker.cpp \
47
multi_path_symex_only_checker.cpp \
58
properties.cpp \
69
report_util.cpp \

src/goto-checker/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
\ingroup module_hidden
2+
\defgroup goto-checker goto-checker
3+
4+
# Folder goto-checker
5+
6+
\author Peter Schrammel
7+
8+
The \ref goto-checker directory contains interfaces for the verification of
9+
goto-programs.
10+
11+
There are three main concepts:
12+
* Property
13+
* Goto Verifier
14+
* Incremental Goto Checker
15+
16+
A property has a `property_id` and identifies an assertion that is either
17+
part of the goto model or generated in the course of executing the verification
18+
algorithm. A verification algorithm determines the `status` of a property,
19+
i.e. whether the property has passed verification, failed, is yet to be
20+
analyzed, etc. See \ref property_infot.
21+
22+
A goto verifier aims at determining and reporting
23+
the status of all or some of the properties, _independently_ of the
24+
actual verification algorithm (e.g. path-merging symbolic execution,
25+
path-wise symbolic execution, abstract interpretation).
26+
See \ref goto_verifiert.
27+
28+
An incremental goto checker is used by a goto verifier to execute the
29+
verification algorithm. Incremental goto checkers keep the state of the
30+
analysis and can be queried by the goto verifier repeatedly to return
31+
their results incrementally. A query to an incremental goto checker
32+
either returns when a violated property has been found or the
33+
verification algorithm has terminated. If a violated property has been
34+
found then additional information (e.g. a trace) can be retrieved
35+
from the incremental goto checker (if it supports that).
36+
See \ref incremental_goto_checkert.
37+
38+
The combination of these three concepts enables:
39+
* _Verification algorithms can be used interchangeably._
40+
There is a single, small interface for our verification engines.
41+
* _Verification results reporting is uniform across all engines._
42+
Downstream tools can use the reporting output without knowing
43+
which verification algorithm was at work.
44+
* _Building variants of verification engines becomes easy._
45+
Goto verifier and incremental goto checker implementations are built from
46+
small building blocks. It should therefore be easy to build variants
47+
by implementing these interfaces instead of hooking into a monolithic engine.
48+
* _The code becomes easier to maintain._
49+
There are N things that do one thing each rather than one thing that does
50+
N things. New variants of verification algorithms can be added and removed
51+
without impacting others.
52+
53+
There are the following variants of goto verifiers at the moment:
54+
* \ref all_properties_verifier_with_trace_storaget : Determines the status of
55+
all properties and outputs results when the verification algorithm has
56+
terminated. A trace ends at a violated property.
57+
* \ref all_properties_verifiert : Determines the status of all properties and
58+
outputs verification results incrementally. In contrast to
59+
\ref all_properties_verifier_with_trace_storaget,
60+
\ref all_properties_verifiert does not require to store any traces.
61+
A trace ends at a violated property.
62+
63+
There are the following variants of incremental goto checkers at the moment:
64+
* \ref multi_path_symex_checkert : The default mode of goto-symex. It explores
65+
all paths and applies aggressive path merging to generate a formula
66+
(aka 'equation') that is passed to the SAT/SMT solver. It supports
67+
determining the status of all properties, but not adding new properties
68+
after the first invocation.
69+
* \ref multi_path_symex_only_checkert : Same as \ref multi_path_symex_checkert,
70+
but does not call the SAT/SMT solver. It can only decide the status of
71+
properties by the simplifications that goto-symex performs.
72+
* There are variants for Java that perform a Java-specific preprocessing:
73+
\ref java_multi_path_symex_checkert,
74+
\ref java_multi_path_symex_only_checkert

src/goto-checker/all_properties_verifier.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@ class all_properties_verifiert : public goto_verifiert
4343
incremental_goto_checkert::resultt::progresst::DONE)
4444
{
4545
// loop until we are done
46+
++iterations;
4647
}
4748
return determine_result(properties);
4849
}
4950

5051
void report() override
5152
{
52-
output_properties(properties, ui_message_handler);
53+
output_properties(properties, iterations, ui_message_handler);
5354
output_overall_result(determine_result(properties), ui_message_handler);
5455
}
5556

5657
protected:
5758
abstract_goto_modelt &goto_model;
5859
incremental_goto_checkerT incremental_goto_checker;
60+
std::size_t iterations = 1;
5961
};
6062

6163
#endif // CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_H

0 commit comments

Comments
 (0)