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 FSharpProjectPackage properly #2058

Merged
merged 2 commits into from
Dec 20, 2016
Merged

Conversation

dungpa
Copy link
Contributor

@dungpa dungpa commented Dec 19, 2016

This is supposed to be part of #2043.
Sorry for missing this earlier.

@@ -355,6 +355,14 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
pIdIco <- 400u
VSConstants.S_OK

override this.Dispose(disposing) =
Copy link
Member

Choose a reason for hiding this comment

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

Will this always happen on a UI thread? should we used interlocked compex on componentID to ensure it's not double disposed, or is double disposing Okay?

Copy link
Member

Choose a reason for hiding this comment

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

I guess I mean double revoking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We guard revoking component by componentId and mgr so I think double revoking should not happen.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't look thread safe. But there may be other mitigations in place.

However, as it stands two threads could both invoke mgr..FRevokeComponent(componentID) simultaneously.

Now that might not be a problem ...
for example if mgr..FRevokeComponent(componentID) is resilient to double revoke.

or
Something higher up the stack is ensuring that two threads can't dispose simultaneous ... for example something enforces that only a single thread at a time is doing the dispose.

to make it threadsafe either grabbing a lock and double checking or using Interlocked.CompareExchange to set componentID back to zero would probably work fine.

Copy link
Contributor Author

@dungpa dungpa Dec 20, 2016

Choose a reason for hiding this comment

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

Good point. I added locking around revoking component bits.

Looking at the old code, the assumption is that the code should be invoked in a single thread https://github.com/dsyme/old-visualfsharp-clones/blob/8130b1429d3fd83a77a07df1bdc07751a6ee6577/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/servicem.fs#L2069-L2078

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me.

Thank you.

Kevin

@@ -355,6 +355,14 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
pIdIco <- 400u
VSConstants.S_OK

override this.Dispose(disposing) =
Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me.

Thank you.

Kevin

@KevinRansom KevinRansom merged commit 07c3f37 into dotnet:master Dec 20, 2016
@dungpa dungpa deleted the disposing branch December 20, 2016 19:39
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.

4 participants