Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access violation calling GitHasUncommitedChanges #145

Closed
gmkado opened this issue Jun 9, 2021 · 8 comments · Fixed by #150
Closed

Access violation calling GitHasUncommitedChanges #145

gmkado opened this issue Jun 9, 2021 · 8 comments · Fixed by #150
Assignees
Labels

Comments

@gmkado
Copy link

gmkado commented Jun 9, 2021

This was working fine last week, not sure what changed, but calling GitHasUncommitedChanges on v1.0.1 throws the following exception:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at LibGit2Sharp.Core.NativeMethods.git_status_list_new(LibGit2Sharp.Core.git_status_list* ByRef, LibGit2Sharp.Core.git_repository*, LibGit2Sharp.Core.GitStatusOptions)
--------------------------------
   at LibGit2Sharp.Core.Proxy.git_status_list_new(LibGit2Sharp.Core.Handles.RepositoryHandle, LibGit2Sharp.Core.GitStatusOptions)
   at LibGit2Sharp.RepositoryStatus..ctor(LibGit2Sharp.Repository, LibGit2Sharp.StatusOptions)
   at LibGit2Sharp.RepositoryExtensions.RetrieveStatus(LibGit2Sharp.IRepository)
   at Cake.Git.GitAliases+<>c.<GitHasUncommitedChanges>b__38_0(LibGit2Sharp.Repository)
   at Cake.Git.Extensions.RepositoryExtensions.UseRepository[[System.Boolean, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Cake.Core.ICakeContext, Cake.Core.IO.DirectoryPath, System.Func`2<LibGit2Sharp.Repository,Boolean>)
   at Cake.Git.GitAliases.GitHasUncommitedChanges(Cake.Core.ICakeContext, Cake.Core.IO.DirectoryPath)
@pascalberger
Copy link
Member

Cake.Git 1.0.1 was released already in March 2021, therefore this can't be related to an update of Cake.Git.

You mention it worked last week. What have you changed? Have you updated the addin or Cake? Have you pinned addin and Cake version? Did you run any OS updates? Do you get the error while running it on the same repository as last week? Do you get the same error on other repositories?

@gmkado
Copy link
Author

gmkado commented Jun 9, 2021

Thanks for the quick response! It looks like there were some security updates that ran yesterday
image

I did not get the error running on the same repository last week. I also get the same error for other repositories. I didn't touch the cake script at all for either repos.

@gmkado
Copy link
Author

gmkado commented Jun 9, 2021

Also this is how I reference the addin:

#addin nuget:?package=Cake.Git&version=1.0.1

@gmkado
Copy link
Author

gmkado commented Jun 15, 2021

Looks like these might be related: libgit2/libgit2sharp#1711

@Xcone
Copy link

Xcone commented Jun 23, 2021

I'm not using this through cake, but I'm using libgit2sharp directly. I also have this issue that since last week suddenly access violations happen when calling RetrieveStatus() of libgit.

        public bool HasUncommittedChanges()
        {
            using (var git = new Repository(Directory.FullName))
            {
                return git.RetrieveStatus().IsDirty;
            }
        }

As you can see, not much happening here on my part. It just dies. If you find any solution or workaround I'd be interested to know.

@augustoproiete
Copy link
Member

FY, we're seeing the same error when running integration tests via CI of this addin:

========================================
Git-HasUncommitedChanges-Dirty
========================================
Checking if repository has uncommited changes...
C:\projects\cake-git\tools\Cake\Cake.exe : Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
At line:1 char:1
+ C:\projects\cake-git\tools\Cake\Cake.exe "build.cake" --target="AppVe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Fatal error. Sy...ory is corrupt.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

https://ci.appveyor.com/project/cakecontrib/cake-git/builds/40242817#L702

@augustoproiete
Copy link
Member

It looks like updating to the latest LibGit2Sharp 0.27.0-preview fixes the issue libgit2/libgit2sharp#1711 (comment)

@augustoproiete
Copy link
Member

@gmkado @Xcone This has been fixed with Cake.Git v1.1.0

#addin "nuget:?package=Cake.Git&version=1.1.0"

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

Successfully merging a pull request may close this issue.

4 participants