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

Fix unsoundess in Resource Leak Checker related to owning fields and EnsuresCalledMethods #4869

Merged
merged 25 commits into from
Aug 17, 2021

Conversation

kelloggm
Copy link
Contributor

@kelloggm kelloggm commented Aug 6, 2021

Fixes #4838.

Merge after #4867.

This is a replacement for #4839, based on the comments on it from @msridhar. It relies on #4867 to resolve the false positives described in the comment chain on #4839.

@msridhar
Copy link
Contributor

msridhar commented Aug 7, 2021

This looks pretty clean! The change looks good to me. Do we have a test where the finalizer does a try-finally and we are able to still verify it?

@kelloggm
Copy link
Contributor Author

kelloggm commented Aug 9, 2021

Do we have a test where the finalizer does a try-finally and we are able to still verify it?

We did not, but I just added one as ReplicaInputStreams2.java.

@kelloggm kelloggm assigned kelloggm and unassigned msridhar Aug 16, 2021
@kelloggm kelloggm assigned msridhar and unassigned kelloggm Aug 16, 2021
Copy link
Contributor

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM; just one style comment

@kelloggm kelloggm requested a review from msridhar August 17, 2021 19:28
@kelloggm kelloggm assigned msridhar and unassigned kelloggm Aug 17, 2021
Copy link
Contributor

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, one more question I forgot to ask before

Comment on lines +30 to +31
ignoredExceptionTypes.add("java.lang.Error");
ignoredExceptionTypes.add("java.lang.RuntimeException");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding these exception types in this PR? Do the tests not pass without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests do not pass without it.

In particular, we get these three false positives:

    3 unexpected diagnostics were found
    CheckFields.java:68: error: (destructor.exceptional.postcondition)
    CreatesMustCallForOverride2.java:38: error: (destructor.exceptional.postcondition)
    CreatesMustCallForOverride2.java:56: error: (destructor.exceptional.postcondition)

For reference, here's the relevant lines of CheckFields:

    @EnsuresCalledMethods(
        value = {"this.finalOwningFoo", "this.owningFoo"},
        methods = {"a"})
    void b() {
      this.finalOwningFoo.a();
      this.finalOwningFoo.c();
      this.owningFoo.a();
    }
  }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this lands we may want to think about another manual update like #4892

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that's really necessary - that run-time errors don't invalidate CalledMethods types follows from the idea that annotations (and therefore types) specify normal behavior, and a run-time exception is definitely not normal behavior.

@msridhar msridhar assigned kelloggm and unassigned msridhar Aug 17, 2021
@kelloggm kelloggm merged commit a5910ad into typetools:master Aug 17, 2021
@kelloggm kelloggm deleted the rlc-twoclose-soundness-2 branch August 17, 2021 21:14
wmdietl pushed a commit to eisop/checker-framework that referenced this pull request Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants