Repository navigation
Description
Requested feature: cbmc and also goto-instrument can be invoked with --validate-goto-model to perform consistency checks on the GOTO model. cbmc furthermore supports --validate-ssa-equation to enable consistency checks on the formula generated during symbolic execution. These bear additional runtime cost, but could help spot bugs creeping in as Kani builds expressions using a completely different code base. CBMC uses these options in its regression test suite.
Use case: Enabling those in regression tests might well be the right approach for Kani as well.
Link to relevant documentation (Rust reference, Nomicon, RFC):
Is this a breaking change? Yes, because there currently are some inconsistencies reported when manually enabling these options on Kani-generated goto binaries.
Test case: Running CBMC on the goto binary attached to diffblue/cbmc#6731:
cbmc test.out --validate-goto-model
CBMC version 5.52.0 (cbmc-5.52.0-61-g686da25177) 64-bit x86_64 linux
Reading GOTO program from file test.out
Generating GOTO Program
--- begin invariant violation report ---
Invariant check failed
File: ../src/goto-programs/goto_function.cpp:43 function: validate
Condition: identifier.empty() || ns.lookup(identifier).is_parameter
Reason: parameter should be marked 'is_parameter' in the symbol table
Backtrace:
build/bin/cbmc(print_backtrace(std::ostream&)+0x50) [0x56243462d600]
build/bin/cbmc(get_backtrace[abi:cxx11]()+0x169) [0x56243462dba9]
build/bin/cbmc(std::enable_if<std::is_base_of<invariant_failedt, invariant_failedt>::value, void>::type invariant_violated_structured<invariant_failedt, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x48) [0x562433c4d618]
build/bin/cbmc(goto_functiont::validate(namespacet const&, validation_modet) const+0x103) [0x562434144543]
build/bin/cbmc(goto_functionst::validate(namespacet const&, validation_modet) const+0x634) [0x5624341485a4]
build/bin/cbmc(initialize_goto_model(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, message_handlert&, optionst const&)+0x9fe) [0x5624341726ee]
build/bin/cbmc(cbmc_parse_optionst::get_goto_program(goto_modelt&, optionst const&, cmdlinet const&, ui_message_handlert&)+0x226) [0x562433c4f4f6]
build/bin/cbmc(cbmc_parse_optionst::doit()+0x58f) [0x562433c5372f]
build/bin/cbmc(parse_options_baset::main()+0x8f) [0x562434655c4f]
build/bin/cbmc(main+0x39) [0x562433c4df19]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f6507d770b3]
build/bin/cbmc(_start+0x2e) [0x562433c4d02e]
--- end invariant violation report ---
Aborted (core dumped)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
- StatusShow more project fieldsBlocked
Activity
zhassan-aws commentedon Apr 6, 2022
It seems that the consistency checks currently fail even on very simple Rust programs, e.g.:
@tautschnig, is there a way to print more information, e.g. the name of the parameter that is failing the consistency checks?
tautschnig commentedon Apr 7, 2022
I'll work on improving the output of those checks, I've myself been caught by this lack of information more than once. That said, however: are you setting
is_parameterat all? Only if so would the name really be helpful, I guess.zhassan-aws commentedon Apr 7, 2022
I don't see
is_parameterset to true anywhere. Which symbols does CBMC expect it to be set for?tautschnig commentedon Apr 8, 2022
All symbols that are function parameters. Presumably there is some code that introduces symbols for function declarations, and that's where
is_parametershould get set.Goto functions validation: provide parameter name
Goto functions validation: provide parameter name
celinval commentedon Jul 18, 2022
I was able to fix the
is_parameterissue. I'll submit a PR soon. However, I'm running into another issue withmemcmp. E.g., with this code:I am getting the following error:
@tautschnig any idea?
Here is the snippet of main.out.demangled.c where memcmp is invoked.
main.symtab.zip
tautschnig commentedon Jul 20, 2022
It seems that there is an inconsistency on the parameter types. Your symbol table includes a declaration of
memcmpthat matches the one that C has, which hasvoid*typed parameters. You then, however, also have function calls tomemcmp, which include a type (as expected). Those calls now have parameters of typeuint8_t.celinval commentedon Jul 20, 2022
Thanks Michael! That message was a bit cryptic for me.
tautschnig commentedon Jul 20, 2022
What a euphemism :-) I locally hacked it to use the
.pretty()output to get the full ireps in order to understand what was going on.1 remaining item
celinval commentedon Jul 21, 2022
This issue seems to be captured here: #1350
Include `symtab2gb` conversion in `--only-codegen` (#1585)
tedinski commentedon Nov 14, 2022
@celinval What's the current status of this? (Just not clear where things left off...)
celinval commentedon Nov 15, 2022
This issue is blocked until we fix #1350.
celinval commentedon Jun 28, 2024
We should revisit this... I noticed the other day that enabling these checks with contracts can trigger consistency check failure.