gradual-verification / gvc0

Gradually Verified C0
6 stars 5 forks source link

BST - Failing series of partial specs when removing imprecision #24

Closed icmccorm closed 2 years ago

icmccorm commented 2 years ago

Description

BST has a total of 157 partial specifications in a single path, where #157 is fully specified. Everything is verifying, but each partial specification from #145 - 149, 155-156 is failing at runtime (stress level 2) with the following error

Error: Field access runtime check failed for struct Node.left

The following source files can be used to recreate this issue. Specifically, compiling imprecise_checked.c0 after modifying the value for stressCaptured on line 329 from 0 to some nonzero value will recreate the failures described below:

Source

The source of the error varies as the workload parameter is changed because a different, random set of nodes are added for each workload value. We have yet to document the location of each failure for every partial spec, but for #145, the original failure at workload level 2 occurs within bst:

void bst(struct Node* root, int min, int max, struct OwnedFields* _ownedFields)
{
  if (root == NULL)
  {
    assert(true);
  }
  else
  {
    assertAcc(_ownedFields, root != NULL ? root->_id : -1, 1, "Field access runtime check failed for struct Node.left");

Changing the parameter from 2 to 20 results in the following runtime check failing at line 519 in tree_add_helper:

assertAcc(_ownedFields, root != NULL ? root->_id : -1, 2, "Field access runtime check failed for struct Node.right4");

Changing the parameter to 23 results in a different runtime check failing within tree_add_helper at line 494:

assertAcc(_ownedFields, root != NULL ? root->_id : -1, 1, "Field access runtime check failed for struct Node.left6");

Contents

Partial spec #145 is created by completing the predicate tree

< //@predicate tree(struct Node* root) = bst(root, -2147483647, 2147483647);
---
> //@predicate tree(struct Node* root) = ?;

This causes imprecision to be removed from the completed specs of the following methods:

The following predicates are still imprecise:

The following methods are still imprecise: