This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Couldn't load subscription status.
- Fork 1.2k
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Find out why / when LibGit2Sharp is crashing #1315
Copy link
Copy link
Closed
Description
This investigation is related to the following issue
GitHub extension crashes when viewing pull requests: #1306
- Crash appears in LibGit2Sharp version: 0.24, 0.25.0-preview-0033
- Crash not yet seen in LibGit2Sharp version: 0.23.0, 0.23.1
How to reproduce
Compile and run the following code in Release configuration.
static void Main(string[] args)
{
var path = @"C:\source\github.com\github\VisualStudio";
for (int count = 0; count < 1000; count++)
{
var status = new Repository(path).RetrieveStatus();
Console.WriteLine(count + ": " + status.IsDirty);
}
}
Eventually something like this will happen:
Here is another very common exception:
System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=LibGit2Sharp
StackTrace:
at LibGit2Sharp.Core.NativeMethods.git_status_list_new(git_status_list*& git_status_list, git_repository* repo, GitStatusOptions options)
at LibGit2Sharp.Core.Proxy.git_status_list_new(RepositoryHandle repo, GitStatusOptions options) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 2931
at LibGit2Sharp.RepositoryStatus..ctor(Repository repo, StatusOptions options) in C:\projects\libgit2sharp\LibGit2Sharp\RepositoryStatus.cs:line 60
at LibGit2Sharp.RepositoryExtensions.RetrieveStatus(IRepository repository) in C:\projects\libgit2sharp\LibGit2Sharp\RepositoryExtensions.cs:line 696
at Libgit2Repro.Program.Main(String[] args) in c:\users\passp\onedrive\documents\visual studio 2015\Projects\Libgit2Repro\Libgit2Repro\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
This only seems to happen when compiled in Release configuration. When compiled in Debug configuration, it can run all 1000 iterations and never crash.
