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

refactor(region): add a constraint for size ghost if ref is null ptr #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LinerSu
Copy link
Contributor

@LinerSu LinerSu commented May 16, 2022

We can also improve the precisons if a given reference constraints is p == NULL.
For instance,

int sz = int_nd();
__CRAB_assume(sz >= 0);
__CRAB_assume(sz < 10);
uint8_t *ptr = (sz == 0) ? NULL : malloc(sizeof(uint8_t) * sz);

We should expect the post invariants (by zones) for ptr is:

sz -> [0, 9] && ptr.address -> [0, +oo]  && sz <= ptr.address + 8 && ptr.offset == 0 && ptr.size == sz

Or we can do better if we use the polyhedra domain:

sz == ptr.size && -sz <= 0 && sz <= 9 && sz-9*ptr.address <= 0; ; ptr.offset == 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant