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

Clean COM wrappers leak: Round 2 #4491

Merged
merged 10 commits into from
Nov 18, 2018

Conversation

bclothier
Copy link
Contributor

@bclothier bclothier commented Nov 4, 2018

  1. This is more exhaustive investigation for any possible leaks. This was done by executing all actions in all toolwindows and tracking down any leaks.
  2. Unloading & reloading was also tested for any leaks (Ref UiDispatcher shutdown/restart problem causing Addin unload/reload to fail #3645)
  3. Temporarily IDisposableAnalyzers which helped few legitimate misuse of IDisposable. However I ended up commenting it out as we have far too many false positive. I left it as comment so once a PR addressing the issue Annotations for cases the analyzer can't figure out. DotNetAnalyzers/IDisposableAnalyzers#126 is merged, we can re-test using it.
  4. Address some comments to the 1st round.

As noted in the comments for #3645, not all items in the COM safe get disposed due to RaceOnRCWDisconnect errors. This is attributed to the fact that there may be other threads running that accesses the SCWs during the shutdown. The PR does not address this as this should be its own PR. One possible fix for that is to implement the VBEEvents.TerminateEvents to put in the necessary kill switch for command buttons and any other objects that needs to query a SCW.

Rubberduck.Core/UI/Command/ExportAllCommand.cs Outdated Show resolved Hide resolved
Rubberduck.Core/UI/Command/FindAllReferencesCommand.cs Outdated Show resolved Hide resolved
Rubberduck.Core/Common/WinAPI/RegistryAccess.cs Outdated Show resolved Hide resolved
Rubberduck.SmartIndenter/IndenterSettings.cs Outdated Show resolved Hide resolved
Rubberduck.SmartIndenter/IndenterSettings.cs Outdated Show resolved Hide resolved
Rubberduck.UnitTesting/UnitTesting/VBEInteraction.cs Outdated Show resolved Hide resolved
Revert changes to RegistryAccess and IndenterSettings -- registry work requires more thought than simply wrapping a new using block.
…nto CleanComSafeLeakRound2

# Conflicts:
#	Rubberduck.VBEditor.VBA/SafeComWrappers/Application/FallbackApp.cs
#	Rubberduck.VBEditor.VBA/SafeComWrappers/VB/VBE.cs
#	RubberduckTests/CodeExplorer/CodeExplorerTests.cs
@@ -235,6 +233,9 @@ public void Dispose()
}

_disposed = true;
_parser?.Dispose();
_vbe?.Dispose();
_tokenSource.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

why are these after the flicking the _disposed switch? That feels a little wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that was what we were supposed to -- if we throw during the dispose, the pooch is totally screwed anyway? At least subsequent calls would not throw again (but we're still screwed).

xmlSS.WriteEndElement(); //Close Worksheet
xmlSS.WriteEndElement(); //Close Workbook
xmlSS.WriteEndDocument();
xmlSS.Close();
Copy link
Member

Choose a reason for hiding this comment

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

While you're touching this, one could try extract these blocks with an explanatory comment into their own methods...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I question whether we should be even doing that. Don't they provide some kind of API for writing OpenXMLs? Doing this all by hand feels wrong.... I'd rather defer that for another PR.

_typeInfosWrapped = _typeInfosWrapped ?? new DisposableList<TypeInfoWrapper>();
_typeInfosWrapped.Add(outVal);
_typeInfosWrapped?.Dispose();
_typeInfosWrapped = _typeInfosWrapped ?? new DisposableList<TypeInfoWrapper>();
Copy link
Member

Choose a reason for hiding this comment

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

and again

Rubberduck.VBEEditor/Events/VbeEvents.cs Outdated Show resolved Hide resolved
RubberduckBaseProject.csproj Show resolved Hide resolved
@bclothier bclothier added PR-Status: Review Requested No more commits, PR is ready for the eyes that need to see it. PR-Status: Conflicting PR can't be merged as it stands, conflicts must be resolved by the author. labels Nov 13, 2018
…nto CleanComSafeLeakRound2

# Conflicts:
#	Rubberduck.CodeAnalysis/QuickFixes/IgnoreOnceQuickFix.cs
#	Rubberduck.Resources/Rubberduck.Resources.csproj
@bclothier bclothier removed the PR-Status: Conflicting PR can't be merged as it stands, conflicts must be resolved by the author. label Nov 17, 2018
@retailcoder retailcoder merged commit 08783ee into rubberduck-vba:next Nov 18, 2018
@bclothier bclothier deleted the CleanComSafeLeakRound2 branch September 1, 2019 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Status: Review Requested No more commits, PR is ready for the eyes that need to see it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants