libgit2 / libgit2/libgit2sharp

Crash in git_diff_tree_to_index when calling Repository.RetrieveStatus

Open
#1,755 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

I originally raised this bug with libgit2 directly but response was that this is in fact a libgit2sharp error.
https://github.com/libgit2/libgit2/issues/5363

Reproduction steps

Use Repository.RetrieveStatus from libgit2sharp from inside Unity3D editor script.

  1. download this: libgit2-git_diff_tree_to_index-Crash.zip
  2. download Unity 2019.3.0f5 (other versions crash as well)
  3. open the above project
  4. select menu item "Git Error/RetrieveStatus - CRASH"
  5. note native crash, with the log below
Expected behavior

No crash, instead returns RepositoryStatus

Actual behavior
git2-106a5f2.dll caused an Access Violation (0xc0000005)
  in module git2-106a5f2.dll at 0033:7cb4ae65.

Stack Trace of Crashed Thread 9380:
0x00007FFC7CB4AE65 (git2-106a5f2) git_diff_tree_to_index
0x00007FFC7CBB4B09 (git2-106a5f2) git_status_list_new
0x0000028C392EADBF (LibGit2Sharp) LibGit2Sharp.Core.NativeMethods.git_status_list_new()
0x0000028C392EAB9B (LibGit2Sharp) LibGit2Sharp.Core.Proxy.git_status_list_new()
0x0000028C392E57FB (LibGit2Sharp) LibGit2Sharp.RepositoryStatus..ctor()
0x0000028C392E49FB (LibGit2Sharp) LibGit2Sharp.Repository.RetrieveStatus()
Version of LibGit2Sharp (release number or SHA1)

git2-106a5f2, but also happens with e.g. git2-7ce88e6 (happened with all versions I tried).

Operating system(s) tested; .NET runtime tested

Windows 10

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 the attached Unity reproduction project and the Repository.RetrieveStatus call described in the issue. Review the native crash stack around git_diff_tree_to_index and git_status_list_new, then verify on Windows 10 that the reproduction no longer crashes and returns RepositoryStatus.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.