Skip to content

Predicate to describe overlapping pointers #7194

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

Closed
feliperodri opened this issue Oct 5, 2022 · 1 comment · Fixed by #7401
Closed

Predicate to describe overlapping pointers #7194

feliperodri opened this issue Oct 5, 2022 · 1 comment · Fixed by #7401
Assignees
Labels
aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts feature request

Comments

@feliperodri
Copy link
Collaborator

CBMC version: 5.67.0
Operating system: N/A

We need to describe pointers that may overlap, for example an array and a pointer within that array. Currently, we have prototype same_space to express this as follows:

bool same_space(const void *a, const void *b) {
    size_t a_size = __CPROVER_OBJECT_SIZE(a);
    size_t a_offset = __CPROVER_POINTER_OFFSET(a);
    void *a_base = a - a_offset;
    size_t temp = nondet_size_t();
    size_t b_delta = MIN(temp, a_size - ((size_t) 1));
    return (b == a_base + b_delta);
}

The issue is that any proof that uses this primitive must disable the pointer-primitive-check CBMC flag, which is something that should be used in memory safety proofs. We need to disable the flag in order to use the __CPROVER_OBJECT_SIZE and __CPROVER_POINTER_OFFSET functions. We should be able to resolve this temporarily by just disabling the flag in a pragma, but this is not supported. There is a GitHub issue addressing this here.

@feliperodri feliperodri added aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts feature request labels Oct 5, 2022
@feliperodri feliperodri self-assigned this Oct 5, 2022
@remi-delmas-3000
Copy link
Collaborator

remi-delmas-3000 commented Dec 5, 2022

PR #7401 adds support for

bool __CPROVER_pointer_in_range_dfcc(void *lb, void *ptr, void *ub);

which holds iff lb and ub are valid pointers to the same object and lb <= ptr && ptr <= ub.

We could close the issue once the PR is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants