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

Lock invariant violation reported too broadly on synchronized methods #889

Closed
JLedelay opened this issue Dec 5, 2022 · 0 comments
Closed
Labels
A-Enh Enhancement M-log Misc: Error reporting and logging

Comments

@JLedelay
Copy link

JLedelay commented Dec 5, 2022

When you fail to re-establish the lock invariant upon exiting a synchronized method, the entire class is reported as the origin for the error.
The following input:

public /*@ lock_invariant Perm(field, write); @*/ class C {
  int field;

  /*@
    requires committed(this);
  @*/
  public synchronized void inc() {
    loseWritePerm();
  }

  //@ requires Perm(field, write);
  public int loseWritePerm();
}

Generates the following output:

======================================
 At dbutils\lock\Test.java:1:1:
--------------------------------------
      [------------------------------------------------------------
    1  public /*@ lock_invariant Perm(field, write); @*/ class C {
    2    int field;
    3
       ... (7 lines omitted)
   11    //@ requires Perm(field, write);
   12    public int loseWritePerms();
   13  }
       -]
   14
--------------------------------------
[1/2] The lock invariant may not be exhaled here, since ...
--------------------------------------
 At dbutils\lock\Test.java:1:27:
--------------------------------------
                                [------------------
    1  public /*@ lock_invariant Perm(field, write); @*/ class C {
                                 ------------------]
    2    int field;
    3
--------------------------------------
[2/2] ... there might not be enough permission to exhale this amount (https://utwente.nl/vercors#invariantFailed:perm)
======================================

This ought to report the method instead, similarly to how a synchronized block is highlighted when it fails to re-establish the lock invariant.

@pieter-bos pieter-bos added A-Enh Enhancement M-log Misc: Error reporting and logging labels Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Enh Enhancement M-log Misc: Error reporting and logging
Projects
None yet
Development

No branches or pull requests

2 participants