-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kani should make use of CBMC's internal consistency checks. #957
Comments
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? |
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 |
I don't see |
All symbols that are function parameters. Presumably there is some code that introduces symbols for function declarations, and that's where |
This validation step failed for Kani-generated GOTO models (cf. model-checking/kani#957), but the error message turned out not to be very useful.
This validation step failed for Kani-generated GOTO models (cf. model-checking/kani#957), but the error message turned out not to be very useful.
I was able to fix the #[kani::proof]
fn main() {
assert!("Bl" == "Bl");
} I am getting the following error:
@tautschnig any idea? Here is the snippet of main.out.demangled.c where memcmp is invoked._Bool <[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal(struct &[u8] self, struct &[u8] other)
{
_Bool var_0;
_Bool var_3;
unsigned long int var_4;
struct &[u8] var_5;
unsigned long int var_6;
struct &[u8] var_7;
unsigned long int size;
struct &[u8] val;
int var_10;
unsigned char *var_11;
unsigned char *var_12;
struct &[u8] <[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_13$$self;
unsigned char *var_14;
unsigned char *var_15;
struct &[u8] <[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_16$$self;
unsigned long int var_17;
struct &[u8] var_18;
struct &[u8] var_19;
struct &[u8] var_20;
bb0:
;
var_5 = self;
var_4 = var_5.len;
var_7 = other;
var_6 = var_7.len;
var_3 = var_4 != var_6;
if(!(var_3 == 0))
{
goto bb1;
bb1:
;
var_0 = 0;
goto bb4;
}
bb2:
;
val = self;
var_18 = (struct &[u8]){ .data=val.data, .len=val.len };
size = 1 * var_18.len;
goto bb5;
bb3:
;
var_0 = var_10 == 0;
bb4:
;
return var_0;
bb5:
;
<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_13$$self = self;
var_19 = (struct &[u8]){ .data=<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_13$$self.data, .len=<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_13$$self.len };
var_12 = var_19.data;
var_11 = var_12;
<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_16$$self = other;
var_20 = (struct &[u8]){ .data=<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_16$$self.data, .len=<[u8] as core::slice::cmp::SlicePartialEq<u8>>::equal$$1$$var_16$$self.len };
var_15 = var_20.data;
var_14 = var_15;
var_17 = size;
var_10=memcmp(var_11, var_14, var_17);
goto bb3;
} |
It seems that there is an inconsistency on the parameter types. Your symbol table includes a declaration of |
Thanks Michael! That message was a bit cryptic for me. |
What a euphemism :-) I locally hacked it to use the |
It looks like rust (and LLVM's) We'll have to special case that. |
This issue seems to be captured here: #1350 |
#957 will need more fixes and discussions to be enabled. In the meantime, this PR includes the symtab2gb conversion step in --only-codegen runs, so that Kani fails if the conversion from Kani-generated symbol tables to GotoC program is invalid.
@celinval What's the current status of this? (Just not clear where things left off...) |
This issue is blocked until we fix #1350. |
We should revisit this... I noticed the other day that enabling these checks with contracts can trigger consistency check failure. |
Requested feature:
cbmc
and alsogoto-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:
The text was updated successfully, but these errors were encountered: