-
Notifications
You must be signed in to change notification settings - Fork 84
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
Reading uninitialized memory gives symbolic value rather than error #920
Comments
I think the quoted para isn't appropriate to the example since all values of 0..255 are okay for a u8. Instead, I now think the cause is the line:
|
We should support the examples from https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html |
Related to diffblue/cbmc#7014 |
It turns out that Kani's own test suite has undefined behaviour that isn't really caught because of that, with a mix of that and the Take the test result3.rs. Then unsigned int foo(struct std::result::Result<u32, Unit> *input)
{
unsigned int var_0;
long int var_2;
unsigned int *num;
bb0:
;
var_2 = (long int)input->case;
if(!(var_2 == 0))
goto bb2;
bb1:
;
num = &input->cases.Ok.0;
var_0 = *num;
goto bb3;
bb2:
;
var_0 = 3;
bb3:
;
return var_0;
} The issue is: the compiler has no connection between the discriminant and the value. Therefore, I have a branch where the chosen case of the union is 0, but the value is still uninitialized. In that case, my execution fails with |
@giltho wrote a test showing this, but we decided not to merge it as a "fixme" since it's more of a feature request, but recording it here for future reference: |
In the following program we read from uninitialized memory so the program is undefined [0]. Using CBMC as our symbolic engine means Kani does not warn of this error. Instead the value of
v[0]
is symbolic/nondet. Adding a "poison" value for freshly allocated objects is likely to be a large change for CBMC. For now, we can document this behavior.[0] https://doc.rust-lang.org/reference/behavior-considered-undefined.html#behavior-considered-undefined
The text was updated successfully, but these errors were encountered: