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: false positives when a resource is allocated and closed in the same expression #6270
Comments
Did some investigation on this one, and it looks like at least one issue is we do not have handling of postconditions when they impact temporary variables. We have special handling here for when a method is directly invoked on an expression that has a temporary variable: Lines 78 to 87 in 49d97d7
We need to extend this logic to handle the case where a postcondition (via Line 1111 in 49d97d7
@kelloggm do you think there's a way we could easily extend this logic with some method overrides? Otherwise we may need to do some copy-pasting. |
If we have a The problem is going to be finding the appropriate tempvar. Copy-pasting code from |
With some more investigation, I'm not sure that our current implementation can handle this case without either a major refactoring, a new CFG API, or both. In particular, the core problem is the way that we track temporary variables. Temporary variables are stored by the Even if we copy code from
As far as I know (@smillst can confirm), there is no way to retrieve a In other words, we need to either:
|
Thanks for digging into this @kelloggm. One question:
At this step the logic must have a handle on the |
Yes, that's what the logic in |
I guess what I don't understand from suggestion (1) is why it would take a |
Sorry to come back to this much later.
It could, but then we'd need to viewpoint adapt the |
The Resource Leak Checker does not accept this code:
this very similar code works:
However, that refactoring is not possible when
method
is a constructorclose
is a call tosuper(...)
orthis(...)
For example:
Below is a more complete set of tests that exercise a few variants of that pattern. The RLC reports false positives for test cases 3-7.
The text was updated successfully, but these errors were encountered: