libgit2 / libgit2/libgit2sharp

Internal ArgumentNullException during Repository.Reset

Open
#1,322 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

We have a tool that regularly runs on a repository to migrate changes between several different repositories. As a part of the process, we do a soft reset of a submodule, which periodically (around one time per week) fails with an ArgumentNullException:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: SafeHandle cannot be null.
    mscorlib.dll!System.StubHelpers.StubHelpers.SafeHandleAddRef(System.Runtime.InteropServices.SafeHandle pHandle, ref bool success) Line 1664
    LibGit2Sharp.dll!LibGit2Sharp.Core.Proxy.git_reset(LibGit2Sharp.Core.Handles.RepositorySafeHandle repo, LibGit2Sharp.ObjectId committishId, LibGit2Sharp.ResetMode resetKind, ref LibGit2Sharp.Core.GitCheckoutOpts checkoutOptions) Line 2615
    LibGit2Sharp.dll!LibGit2Sharp.Repository.Reset(LibGit2Sharp.ResetMode resetMode, LibGit2Sharp.Commit commit, LibGit2Sharp.CheckoutOptions opts) Line 1002
    LibGit2Sharp.dll!LibGit2Sharp.Repository.Reset(LibGit2Sharp.ResetMode resetMode, LibGit2Sharp.Commit commit) Line 985

Unfortunately, I do not have a specific repo; every time this happens a rerun works properly again.

Version Consumed: 0.22. I'm not aware of this happening in an earlier version, but we had enough bugs in the tool itself that it's quite possible we never picked this up in the noise.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Repository.Reset and the Proxy.git_reset call shown in the stack trace, using the reported LibGit2Sharp 0.22 context. Investigate how the repository handle and soft-reset inputs are passed during submodule resets; the issue provides no reproducible repository, so done requires isolating the intermittent null-handle cause and verifying that the reset no longer throws.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.