Skip to content

Fixes Issue #1071: Deadlock in Submodules when Directory Structure Changes #1070

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

Merged
merged 1 commit into from
Jun 3, 2015
Merged

Fixes Issue #1071: Deadlock in Submodules when Directory Structure Changes #1070

merged 1 commit into from
Jun 3, 2015

Conversation

whoisj
Copy link

@whoisj whoisj commented Jun 3, 2015

If the underlying directory structure has changed (deleted, renamed, etc) an invalid handle is correctly returned by Libgit2. Attempting to convert the invalid handle directly into an ObjectID results in an exception being thrown, causing the Lazy<ObjectId>.Value call to never return, resulting in a deadlock.

This fixes that by examining the handle before calling .MarshalAsObjectId() and returning a null value if the handle is invalid.

Fixes Issue #1071

PS.
Yes I see the whitespace changes... I've given up in my fight with the Visual Studio auto-formatter, it seems determined to remove those extra characters; I'm going to let it because I cannot seem to stop it. 🐑 😩

@whoisj whoisj changed the title Fixes Issue #3180 Fixes Issue #1071: Deadlock when Directory Structure Changes Jun 3, 2015
@whoisj whoisj changed the title Fixes Issue #1071: Deadlock when Directory Structure Changes Fixes Issue #1071: Deadlock in Submodules when Directory Structure Changes Jun 3, 2015
}
else
{
return handle.MarshalAsObjectId();
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we rather change MarshalAsObjectId to let it handle the (handle.IsZero || handle.IsInvalid) logic? Or are there potential side-effects with this approach?

@jamill
Copy link
Member

jamill commented Jun 3, 2015

Thanks!

Could we put this check in the call to MarshalAsObjectId() or some variant that that returns ObjectId?

@nulltoken
Copy link
Member

Yes I see the whitespace changes...

@whoisj Have you considered partial staging? This would allow you to only pick changes that you're willing to introduce.

@whoisj
Copy link
Author

whoisj commented Jun 3, 2015

Pushed a simpler change with the same effect.

Thanks @nulltoken and @jamill

nulltoken added a commit that referenced this pull request Jun 3, 2015
Fixes Issue #1071: Deadlock in Submodules when Directory Structure Changes
@nulltoken nulltoken merged commit 7202df7 into libgit2:vNext Jun 3, 2015
@nulltoken
Copy link
Member

@whoisj 😍

@nulltoken nulltoken added this to the v0.22 milestone Jun 3, 2015
@whoisj whoisj deleted the fix-crash-submodule-delete branch June 5, 2015 21:10
@nulltoken
Copy link
Member

Published as NuGet pre-release package LibGit2Sharp.0.22.0-pre20150606092322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants