Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

NGit library hangs at application shutdown (_object_87::~_object_87 never called) #9

Open
sehe opened this issue Jun 10, 2011 · 9 comments

Comments

@sehe
Copy link

sehe commented Jun 10, 2011

BatchingProgressMonitor's alarmQueue is preventing application exit with NGit.

The destructor of _object_87 is never called, causing the thread pool (alarmQueue in BatchingProgressMonitor) to hang indefinitely.

I have proof-of-concepted a workaround based on calling alarmQueue.ShutdownNow() explicitely, see here

http://stackoverflow.com/questions/6310691/some-ngit-stuff-prevents-c-application-from-shutting-down-correctly/6311193#6311193

Minimal failing example:

using System;
using NGit;
using NGit.Api;
using NGit.Transport;

namespace Stacko
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Git myrepo = Git.Init().SetDirectory(@"/tmp/myrepo.git").SetBare(true).Call();
            {
                var fetchResult = myrepo.Fetch()
                    .SetProgressMonitor(new TextProgressMonitor())
                    .SetRemote(@"/tmp/initial")
                    .SetRefSpecs(new RefSpec("refs/heads/master:refs/heads/master"))
                    .Call();
                //
                // Some other work...
                //
                myrepo.GetRepository().Close();
            }
            System.GC.Collect();

#if false
            System.Console.WriteLine("Killing");
            BatchingProgressMonitor.ShutdownNow();
#endif
            System.Console.WriteLine("Done");

        }
    }
}

using the helper in BatchingProgressMonitor:

public static void ShutdownNow()
{
    alarmQueue.ShutdownNow();
}

Tested platforms:

  1. Linux (Mono 2.6.7, .NET 3.5)
  2. Linux (Mono 2.11, .NET 4.0)
@WilbertOnGithub
Copy link

I have the same problem when trying to use NGit on Windows. Calling the library results in my test application not exiting.

Basically when I use the API to try to clone a local git repository, the cloning works fine. However, the application never exits. In the current state NGit is not usable to build Git clients.

@alanmcgovern
Copy link
Member

These issues have been fixed as far as I can tell. You shouldn't need to explicitly shut down the threads anymore. Please re-open the issue if you can reproduce hangs/deadlocks with the latest translated code.

@WilbertOnGithub
Copy link

After compiling the latest version of NGit from source, I could no longer reproduce the issue of the hanging threads. Looks fine to me.

@alanmcgovern
Copy link
Member

Great, thanks for confirming that!

@damianh
Copy link

damianh commented Sep 3, 2012

Hi Alan, has the ngit nuget package been updated with this fix? Asking because I just experienced this issue.

Edit: looks like it hasn't. Can it be updated?

@alanmcgovern
Copy link
Member

I don't know who handles the nuget package. They'd need to be pinged to do a new release with all the fixes.

@damianh
Copy link

damianh commented Sep 25, 2012

@xpaulbettsx The NGit nuget package is well out of date, can you updated it pls? Thx.

@alanmcgovern Any interest in taking over the nuget package ownership? I can do a PR with the nuspec bits, if @xpaulbettx will add you as package co-owner.

@alanmcgovern
Copy link
Member

@damianh, i don't know much about the packaging side of nuget, but if it's not too complicated I don't mind keeping it updated.

@alanmcgovern alanmcgovern reopened this Sep 25, 2012
@damianh
Copy link

damianh commented Sep 25, 2012

Yeah, it's dead simple - a .nuspec file and an command line exe to create the package and upload to nuget.org.

Thx for the port too ;)

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

No branches or pull requests

4 participants