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

Wand Packaging Fails when a field is used alongside a function that requires it #416

Open
dewert99 opened this issue Jun 8, 2022 · 0 comments
Labels
bug Something isn't working magic-wands

Comments

@dewert99
Copy link
Contributor

dewert99 commented Jun 8, 2022

The following example fails:

field f: Int

function get_f(r: Ref): Int
requires acc(r.f) {
    r.f
}

method test0(x: Ref)
{
  package acc(x.f) && get_f(x) == x.f --* true
}

Looking at the generated Boogie:

...
// -- Check definedness of get_f(x) == x.f
            if (*) {
              // Exhale precondition of function application
              // Phase 1: pure assertions and fixed permissions
              perm := NoPerm;
              perm := perm + FullPerm;
              if (perm != NoPerm) {
                assert {:msg "  Precondition of function get_f might not hold. There might be insufficient permission to access x.f ([email protected]) [37]"}
                  perm <= Ops_1Mask[x, f_7];
              }
              Ops_1Mask[x, f_7] := Ops_1Mask[x, f_7] - perm;
              // Finish exhale
              havoc ExhaleHeap;
              b_1_1 := b_1_1 && IdenticalOnKnownLocations(Ops_1Heap, ExhaleHeap, Ops_1Mask);
              Ops_1Heap := ExhaleHeap;
              // Stop execution
              b_1_1 := false;
            }
            assert {:msg "  Packaging wand might fail. There might be insufficient permission to access x.f ([email protected]) [38]"}
              HasDirectPerm(Ops_1Mask, x, f_7);
            b_1_1 := b_1_1 && state(Ops_1Heap, Ops_1Mask);
...

It seems like instead of assuming false when we exhale the preconditions of get_f we just set b_1_1 to false. This does nothing to stop execution so we continue to assert access to x.f which we no longer have since we exhaled it.

@dewert99 dewert99 added bug Something isn't working magic-wands labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working magic-wands
Projects
None yet
Development

No branches or pull requests

1 participant