Skip to content
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

Create an API to check valid raw pointer #2690

Closed
celinval opened this issue Aug 17, 2023 · 5 comments
Closed

Create an API to check valid raw pointer #2690

celinval opened this issue Aug 17, 2023 · 5 comments
Assignees
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one. T-CBMC Issue related to an existing CBMC issue

Comments

@celinval
Copy link
Contributor

Requested feature: Create a method to ensure a pointer is valid.
Use case: Verifying unsafe operations
Link to relevant documentation (Rust reference, Nomicon, RFC):

The method I was thinking would be something like:

pub fn is_ptr_valid<T: ?Sized>(ptr: *const T) -> bool {
    let sz = intrinsics::size_of_val(ptr);
    // Kani intrinsic that translates to __CPROVER_r_ok
    is_read_ok(ptr, sz)
}
@celinval celinval added the [C] Feature / Enhancement A new feature request or enhancement to an existing feature. label Aug 17, 2023
@adpaco-aws
Copy link
Contributor

#1496 is less detailed but looks similar

@celinval
Copy link
Contributor Author

I'll update #1496 and close this one since there's some interesting discussions there. Thanks @adpaco-aws!

@celinval
Copy link
Contributor Author

Reopening this one, since __CPROVER_r_ok does not match the behavior requested in this issue.

@celinval celinval reopened this Feb 22, 2024
@celinval
Copy link
Contributor Author

Note that this is blocked since there is no way to encode this in CBMC today. I've created a request here: diffblue/cbmc#8217

@celinval celinval added [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one. T-CBMC Issue related to an existing CBMC issue labels Feb 22, 2024
@celinval celinval self-assigned this Feb 29, 2024
@feliperodri
Copy link
Contributor

#3107 solves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one. T-CBMC Issue related to an existing CBMC issue
Projects
None yet
Development

No branches or pull requests

3 participants