libgit2 / libgit2/libgit2sharp

System.AccessViolationException on CherryPick

Open
#1,883 0 comments 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

You are opening a bug report against the LibGit2Sharp project: we
use GitHub Issues for tracking bug reports and feature requests. If
you have a question about an API or usage, please ask on StackOverflow:
http://stackoverflow.com/questions/tagged/libgit2sharp.

Otherwise, to report a bug, please fill out the reproduction steps
(below) and delete these introductory paragraphs. Thanks!

Reproduction steps
public static void Main(string[] args) {
    Download();
}

public static Tag GetLatestVersion()
{
    using Repository repo = new("./");
    return repo.Tags
        // Order by version: 2.0.0, 1.2.0, 1.0.0, etc
        .OrderByDescending(tag => tag.FriendlyName)
        // Gets latest tag
        .First();
}

public static void Download()
{
    using Repository repo = new("./");
    Tag latestTag = GetLatestVersion();
    CherryPickOptions cherryPickOptions = new();
    cherryPickOptions.FailOnConflict = false;
    cherryPickOptions.FileConflictStrategy = CheckoutFileConflictStrategy.Theirs;
    cherryPickOptions.FindRenames = true;
    cherryPickOptions.IgnoreWhitespaceChange = false;
    repo.CherryPick((Commit)latestTag.Target, new Signature(Program.Config.Update.GitName, Program.Config.Update.GitEmail, DateTimeOffset.Now), cherryPickOptions);
}
Expected behavior

Specific commit from tag to be cherrypicked

Actual behavior

System.AccessViolationException exception thrown. Message:

An unhandled exception of type 'System.AccessViolationException' occurred in LibGit2Sharp.dll:
'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
<Cannot evaluate the exception stack trace>
Version of LibGit2Sharp (release number or SHA1)

0.26.2 (Nuget)

Operating system(s) tested; .NET runtime tested

Windows 10 64bit; Dotnet 5.0.202

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 supplied C# Download and GetLatestVersion reproduction, especially the repo.CherryPick call, using LibGit2Sharp 0.26.2 on Windows 10 x64 with .NET 5. Trace the CherryPick execution from this entry point and verify that the access violation no longer occurs and the tagged commit is cherrypicked as expected.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.