Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
Fixes VSTS Bug 985666: [FATAL] SigAbrt exception in
Browse files Browse the repository at this point in the history
LibGit2Sharp.dll!LibGit2Sharp.Core.Handles.RepositoryHandle::Free+0

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/985666
  • Loading branch information
mkrueger committed Oct 24, 2019
1 parent 3d42df3 commit 18f1f13
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void ThawEvents ()
FileService.ThawEvents ();
}

object repositoryDisposeLock = new object ();
protected override void Dispose (bool disposing)
{
if (IsDisposed)
Expand All @@ -296,20 +297,24 @@ protected override void Dispose (bool disposing)
gitLock?.Dispose ();
if (rootRepository != null) {
DedicatedOperationFactory.StartNew (() => {
try {
rootRepository?.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
if (cachedSubmodules != null) {
foreach (var submodule in cachedSubmodules) {
if (submodule?.Item2 != null) {
try {
submodule?.Item2.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
lock (repositoryDisposeLock) {
try {
rootRepository?.Dispose ();
rootRepository = null;
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
if (cachedSubmodules != null) {
foreach (var submodule in cachedSubmodules) {
if (submodule?.Item2 != null) {
try {
submodule?.Item2.Dispose ();
} catch (Exception e) {
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
}
}
}
cachedSubmodules = null;
}
}
}).Wait ();
Expand All @@ -322,8 +327,6 @@ protected override void Dispose (bool disposing)
base.Dispose (disposing);

watcher = null;
rootRepository = null;
cachedSubmodules = null;
}

public override string[] SupportedProtocols {
Expand Down

0 comments on commit 18f1f13

Please sign in to comment.