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

Commit 18f1f13

Browse files
committed
Fixes VSTS Bug 985666: [FATAL] SigAbrt exception in
LibGit2Sharp.dll!LibGit2Sharp.Core.Handles.RepositoryHandle::Free+0 https://devdiv.visualstudio.com/DevDiv/_workitems/edit/985666
1 parent 3d42df3 commit 18f1f13

File tree

1 file changed

+17
-14
lines changed
  • main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git

1 file changed

+17
-14
lines changed

main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ void ThawEvents ()
285285
FileService.ThawEvents ();
286286
}
287287

288+
object repositoryDisposeLock = new object ();
288289
protected override void Dispose (bool disposing)
289290
{
290291
if (IsDisposed)
@@ -296,20 +297,24 @@ protected override void Dispose (bool disposing)
296297
gitLock?.Dispose ();
297298
if (rootRepository != null) {
298299
DedicatedOperationFactory.StartNew (() => {
299-
try {
300-
rootRepository?.Dispose ();
301-
} catch (Exception e) {
302-
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
303-
}
304-
if (cachedSubmodules != null) {
305-
foreach (var submodule in cachedSubmodules) {
306-
if (submodule?.Item2 != null) {
307-
try {
308-
submodule?.Item2.Dispose ();
309-
} catch (Exception e) {
310-
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
300+
lock (repositoryDisposeLock) {
301+
try {
302+
rootRepository?.Dispose ();
303+
rootRepository = null;
304+
} catch (Exception e) {
305+
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
306+
}
307+
if (cachedSubmodules != null) {
308+
foreach (var submodule in cachedSubmodules) {
309+
if (submodule?.Item2 != null) {
310+
try {
311+
submodule?.Item2.Dispose ();
312+
} catch (Exception e) {
313+
LoggingService.LogInternalError ("Disposing LibGit2Sharp.Repository failed", e);
314+
}
311315
}
312316
}
317+
cachedSubmodules = null;
313318
}
314319
}
315320
}).Wait ();
@@ -322,8 +327,6 @@ protected override void Dispose (bool disposing)
322327
base.Dispose (disposing);
323328

324329
watcher = null;
325-
rootRepository = null;
326-
cachedSubmodules = null;
327330
}
328331

329332
public override string[] SupportedProtocols {

0 commit comments

Comments
 (0)