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

Dispose various locations using PEReader #74226

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Jul 1, 2024

Attempt to address https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2104770

Multiple hdmps gathered for this bug indicate a leak of native memory in NativeHeapMemoryBlock+DisposableData. Tracking this backwards through code leads to a PEReader leak, but I wasn't able to keep tracking back from the data in the dmps. Looking at the PEReader objects in the dmp, I was able to infer that the PEStreamOptions.PrefetchEntireImage option was set when creating the PEReader.

This led to the most likely culprit, CSharpDecompilationService.PerformDecompilation not disposing the PEFile it owns.

Additionally, I noticed CompilationOutputs.TryCopyPdbToAsync wasn't disposing a PEReader it owned through the DebugInformationReaderProvider it owns from the call to OpenPdb.

Attempt to address https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2104770

Multiple hdmps gathered for this bug indicate a leak of native memory in NativeHeapMemoryBlock+DisposableData. Tracking this backwards through code leads to a PEReader leak, but I wasn't able to keep tracking back from the data in the dmps. Looking at the PEReader objects in the dmp, I was able to infer that the PEStreamOptions.PrefetchEntireImage option was set when creating the PEReader.

This led to the most likely culprit, CSharpDecompilationService.PerformDecompilation not disposing the PEFile it owns.

Additionally, I noticed CompilationOutputs.TryCopyPdbToAsync wasn't disposing a PEReader it owned through the DebugInformationReaderProvider it owns from the call to OpenPdb.
@ToddGrun ToddGrun requested a review from tmat July 1, 2024 21:12
@ToddGrun ToddGrun requested a review from a team as a code owner July 1, 2024 21:12
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 1, 2024
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Jul 2, 2024

@tmat -- ptal

@ToddGrun ToddGrun merged commit d9f63b6 into dotnet:main Jul 3, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 3, 2024
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 P1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants