-
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
Spurious failure due to pointer operation returning non-deterministic value for dangling pointer #3670
Comments
@tautschnig do you think you can take a look at this one to see if the inconsistency is coming from Kani or CBMC? Thanks! |
This appears to be a bug in CBMC as disabling simplification makes the property fail even when |
Turns out that CBMC may be doing something questionable, but the true problem remains with the input: Kani will happily report this problem on this example with So I'd rather claim the problem is in the lack of (default) checks enabled by Kani?! |
@tautschnig do you think we should instantiate pointer validity checks for each occurrence of pointer-integer conversions during the GOTO codegen from Kani ? let ptr = addr() as *const u8;
/* assert(__CPROVER_r_ok(ptr, 0)) */ |
To me, that seems like a good idea. Though I don’t know how easy that is, e.g., with transmute to a union that includes a pointer-typed member. |
Wait, wouldn't that cause spurious counter examples with slices and vectors? This issue is showing up because the standard library encodes length of a ZST iterator by casting the length as a pointer. |
Is that defined behaviour in Rust? Given all the talk that some integer (Boolean?) types must not have values outside a certain range I am wondering whether pointers do have a similar constraint to them? |
Should be addressed by diffblue/cbmc#8497. |
Yes. That's a well defined behavior. Raw pointers don't have any validity requirements. |
diffblue/cbmc#8497 has been merged and I have confirmed that we now get consistent results. We should close this issue with the next CBMC release (and Kani using that newer version). |
And which behavior is that? Will the verification succeed? |
My apologies for not having clarified that: yes, verification now consistently succeeds. (Which should be the correct result given all pointer handling is well-defined for Rust.) |
I've built CBMC from scratch and I was able to verify that it fixes all the harnesses that are currently commented out in model-checking/verify-rust-std#148. Thanks! Looking forward for the next CBMC release. |
Note that there is also a harness commented out in model-checking/verify-rust-std#122 that needs to be updated once we fix this issue. |
This requires the fix from: - model-checking/kani#3670
Upgrade CBMC to its latest release. Resolves: #3670 Co-authored-by: tautschnig <1144736+tautschnig@users.noreply.github.com>
This requires the fix from: - model-checking/kani#3670
In #148 and #122, we had to comment out a few harnesses due to the issue model-checking/kani#3670. But now that the fix has been pushed, we can enable them.
With model-checking/kani#3670 having been addressed we re-enabled harnesses in model-checking#211. Yet the comment explaining previously-commented-out-harnesses stayed in place. Removing it for it no longer applies.
With model-checking/kani#3670 having been addressed we re-enabled harnesses in #211. Yet the comment explaining previously-commented-out-harnesses stayed in place. Removing it for it no longer applies. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
I tried this code:
using the following command line invocation:
with Kani version: 0.56.0 (verify-rust-std branch)
I expected to see this happen: The verification result should be the same as the one where we assign
addr
directly.Instead, this happened: Assigning the address using
any_where
makes the harness fail, while it succeeds when using the concrete value.The text was updated successfully, but these errors were encountered: