-
Notifications
You must be signed in to change notification settings - Fork 353
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: inconsistent behavior for ownership transfer in constructor #6179
Comments
Thanks for the report @Calvin-L. I think an error should be reported for the second constructor as well, since if it terminates exceptionally, there will be no reference to a |
After further discussion with @kelloggm and @Nargeshdb I think the above comment is wrong. We now think that We need to test how we handle calls to methods with We also need to update our documentation on |
I think I agree. Here's a related thought: The "transfer ownership only on normal return" rule would also address a secret fear of mine: when you call a method or constructor, the JVM can throw certain exceptions (e.g. FWIW I am firmly in the camp that there are no safe ways to handle those Errors, and that nobody should try... but the reality is that lots of programs catch |
@Calvin-L unfortunately none of us has had time to work on this one yet. If you're able to contribute a PR that would be much appreciated. |
This change was discussed here: typetools#6179 (comment) This commit only does half the work; the RLC still requires methods with `@Owning` parameters to satisfy their must-call obligations on all paths. We can weaken that requirement later.
Consider:
The resource leak checker reports an error for the first constructor, but not the second:
I think it should report an error for both constructors or neither. I am not sure which it should be.
The text was updated successfully, but these errors were encountered: