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

False positive leak on Task<> #175

Open
matjin opened this issue Oct 7, 2022 · 0 comments
Open

False positive leak on Task<> #175

matjin opened this issue Oct 7, 2022 · 0 comments

Comments

@matjin
Copy link
Contributor

matjin commented Oct 7, 2022

image

image

Methods that return a task which wraps a class that has underlying resources can cause Infer# to report a false positive on the underlying resources. In this case, it reports on the FileStream object here.

This happens because the ultimate TakeAndDispose object is not actually returned (the compiler-generated "MoveNext()" method actually returns null), but is rather still reachable within the broader program space via the method "_fun_Void AsyncTaskMethodBuilder`1<!0>.SetResult(!0)" as seen here:

n$18=_fun_Void AsyncTaskMethodBuilder1<!0>.SetResult(!0)(n$15.InferResourceLeakTests$d__1.<>t__builder:System.Runtime.CompilerServices.AsyncTaskMethodBuilder1*,n$17:TakeAndDispose*) [line 136, column 5];

There is at present no model for SetResult, so it is unknown and hence Infer doesn't actually know that TakeAndDispose (and therefore its underlying FileStream) are still reachable in the program space. TakeAndDispose will not be reported upon because Infer suppresses the reporting of types that are passed to unknown functions as in this case. However, the FileStream doesn't also get suppressed and therefore gets reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant