Skip to content

Tactical mem leak fix for aggregation - #673

Closed
Scott Jones (Scottj1s) wants to merge 4 commits into
masterfrom
scottj1s/mem_leak
Closed

Tactical mem leak fix for aggregation#673
Scott Jones (Scottj1s) wants to merge 4 commits into
masterfrom
scottj1s/mem_leak

Conversation

@Scottj1s

@Scottj1s Scott Jones (Scottj1s) commented Jan 17, 2021

Copy link
Copy Markdown
Member

My main concern with this technique is that when _inner is disposed before its owner is finalized, the finalizer has no chance to detach and the refcount is too low by 1. Since finalizers can run on any thread, in any order, I'm not confident that keeping the inner refcount artificially low is a reliable fix here. In fact, I think any approach that tries to do so is doomed. There's just no safe way to defer an AddRef while still holding onto a COM pointer - it's a time bomb.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursory comments - will look in more detail next week.

Comment thread src/Directory.Build.targets
Comment thread src/WinRT.Runtime/WinRT.Runtime.csproj Outdated
Comment thread src/WinRT.Runtime/ObjectReference.cs Outdated
Comment thread src/WinRT.Runtime/ObjectReference.cs
Comment thread src/WinRT.Runtime/ComWrappersSupport.net5.cs Outdated
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member


// Manual for now - verify that all APIs targeting 19041 generate a warning
// Consider invoking roslyn and scraping/analyzing output as an automated test
private void Test()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a feedback for this PR, but as an FYI, we can probably automate this test this by creating a C# compilation context and triggering a compilation on it and then checking for diagnostics. An example of this is the diagnostics test which Joshua wrote which do this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to open an issue with specific suggestion

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

Successfully merging this pull request may close these issues.

3 participants