-
Notifications
You must be signed in to change notification settings - Fork 357
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
Resource Leak Checker: Verify @EnsuresCalledMethods
calling @Owning
even on exceptional paths
#5734
Comments
@Calvin-L am I right that in light of the changes in #6241, the checker is behaving correctly for the example above in reporting a warning? I think to get the test case to pass, we need to write: @InheritableMustCall("dispose")
public class OwningEnsuresCalledMethods {
@Owning Socket con;
@EnsuresCalledMethods(value = "this.con", methods = "close")
void dispose() throws IOException {
closeCon(con);
}
@EnsuresCalledMethods(value = "#1", methods = "close")
static void closeCon(Socket con) throws IOException {
con.close();
}
} UPDATE: actually, no, the above test case should not pass the type checker either, since typically |
There are two ways to get that test case to pass:
Although, I have a secret plan for this use case (and by extension, surprisingly, #6204): Add a new annotation (or an option to See tentative commits: |
@Calvin-L looks very promising. It would be a breaking change, and we'd have to discuss naming, but I am in favor of the approach suggested by your tentative commits. |
I agree with @msridhar that this is a good idea, and I'm in favor of a change along these lines. |
After #5733, I would expect this code to pass the Resource Leak Checker:
The reason is that
@Owning
guarantees the@MustCall
method is invoked on all paths, including exceptional paths, and the Called Methods Checker code should be propagating called methods along both normal and exceptional paths. But, we still get adestructor.exceptional.postcondition
for thedispose()
method above. We should investigate.The text was updated successfully, but these errors were encountered: