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 S2930 FN: Track System.Threading.CancellationTokenSource #6050

Closed
fraser-lowndes opened this issue Aug 30, 2022 · 2 comments · Fixed by #8302
Closed

Fix S2930 FN: Track System.Threading.CancellationTokenSource #6050

fraser-lowndes opened this issue Aug 30, 2022 · 2 comments · Fixed by #8302
Assignees
Labels
Area: C# C# rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Milestone

Comments

@fraser-lowndes
Copy link

System.Threading.CancellationTokenSource implements IDisposable but isn't tracked by S2930. This may not have been a 'blocker' when the rule was originally added however, due to an optimisation added in .NET Core 2.1, instantiating a CancellationTokenSource creates objects (Linked1CancellationTokenSource, CallbackNode) which are never GC'd. This leads to a memory leak, as has happened to me as well as numerous other projects, including the .NET MongoDB driver.

Given the impact of not disposing these objects, I propose they're added to S2930. If this is OK'd I should be able to get it done.

@andrei-epure-sonarsource
Copy link
Contributor

Thank you for opening this issue, @fraser-lowndes . Your feedback helps us improve our products.

We will look at it as soon as possible. After we confirm the issue, we will add labels and put it in our backlog. Once it's triaged by us, you can open a PR for it.

@pavel-mikula-sonarsource
Copy link
Contributor

Hi @fraser-lowndes ,

Thank you for suggesting this idea. I'm confirming this as False Negative and we'd like to add that into our rule.

We'd also welcome your contribution on this topic if you'd like to create a PR. You will need these files:

@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title S2930: Track System.Threading.CancellationTokenSource Fix S2930 FN: Track System.Threading.CancellationTokenSource Nov 2, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Type: False Negative Rule is NOT triggered when it should be. Area: C# C# rules related issues. labels Nov 2, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 9.14 milestone Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants