-
Notifications
You must be signed in to change notification settings - Fork 95
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
Proposal for new Kani API similar to CPROVER_r_ok
and CPROVER_w_ok
#3672
Comments
Hi @QinyuanWu, just so I make sure I understand the request. Would you like an option that you can provide the size to be read or a function that only checks allocation status (or both)? The |
@celinval We'd like an option to pass a specific size as the parameter to indicate the number of bytes we'd like to check just like the CBMC version:
For allocation status checks I would prefer separate APIs so that it's clear from the language of the contract regarding what properties are checked. |
Hi @QinyuanWu, we can definitely add a new API that accepts different number of elements and potentially number of bytes. I'm not so sure about the fine grained APIs, since these APIs are all fairly unstable, and some checks are still missing, I would prefer not exposing them. I also worry about making contracts very verbose and more error prone. For example, we have a lot of contracts that use kani/library/kani_core/src/mem.rs Lines 122 to 134 in 9b2bbd3
And this is still incomplete since we are not handling alias yet. BTW, you can take a look at #1496 for more background on why we don't directly expose CBMC's APIs. |
@celinval Thank you and I agree with your point. Look forward to the new |
Requested feature: Kani API to verify whether a segment in memory is valid for read or write, similar to
CPROVER_r_ok
andCPROVER_w_ok
Use case: Writing function contracts that meet the safety requirement where the pointer must be valid for reads or writes of a certain number of bytes. std::ptr::copy is an example.
Link to relevant documentation (Rust reference, Nomicon, RFC):
CPROVER memory primitives
The current workaround is to cast the pointer to the size of the number of bytes that need to be checked and use
ub_checks::can_dereference
on the pointer. However, a specific API likeCPROVER_r_ok
andCPROVER_w_ok
would be more accurate. Thank you!@Dhvani-Kapadia @zhassan-aws @celinval
The text was updated successfully, but these errors were encountered: