Skip to content

Commit

Permalink
In failure cases for is_fresh, create nondet pointer to null or uniqu…
Browse files Browse the repository at this point in the history
…e empty object.

Removes nondeterminism on the pointer offset but solves performance problem with quantifiers.
  • Loading branch information
Remi Delmas committed Jan 14, 2025
1 parent f8448a6 commit 2d8ab18
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions src/ansi-c/library/cprover_contracts.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,16 @@ __CPROVER_HIDE:;
}
if(__VERIFIER_nondet___CPROVER_bool())
{
// make pointer invalid, empty value set and nondet bit pattern
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
*elem = (void *)dummy;
// in the failure case, make pointer null or pointing to a unique
// dummy object of size 0.
if(__VERIFIER_nondet___CPROVER_bool())
{
*elem = (void *)0;
}
else
{
*elem = __CPROVER_allocate(0, 0);
}
return 0;
}
void *ptr = __CPROVER_allocate(size, 0);
Expand Down Expand Up @@ -1266,9 +1273,16 @@ __CPROVER_HIDE:;
}
if(__VERIFIER_nondet___CPROVER_bool())
{
// make pointer invalid, empty value set and nondet bit pattern
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
*elem = (void *)dummy;
// in the failure case, make pointer null or pointing to a unique
// dummy object of size 0.
if(__VERIFIER_nondet___CPROVER_bool())
{
*elem = (void *)0;
}
else
{
*elem = __CPROVER_allocate(0, 0);
}
return 0;
}
void *ptr = __CPROVER_allocate(size, 0);
Expand Down Expand Up @@ -1372,9 +1386,16 @@ __CPROVER_HIDE:;
{
if(__VERIFIER_nondet___CPROVER_bool())
{
// make pointer invalid, empty value set and nondet bit pattern
__CPROVER_size_t dummy = __VERIFIER_nondet_size();
*ptr = (void *)dummy;
// in the failure case, make pointer null or pointing to a unique
// dummy object of size 0.
if(__VERIFIER_nondet___CPROVER_bool())
{
*ptr = (void *)0;
}
else
{
*ptr = __CPROVER_allocate(0, 0);
}
return 0;
}

Expand Down

0 comments on commit 2d8ab18

Please sign in to comment.