-
Notifications
You must be signed in to change notification settings - Fork 899
RepositoryStatus sometimes crashes with an AccessViolationException #1513
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
Comments
@jcansdale How many times do you have to run the program to trigger the crash? What framework are you using when you experience the crash? Using However, I wasn't able to fully clone https://github.com/github/VisualStudio.git because it has a private submodule that I don't have access to:
That might be why I'm not able to see it crash. Do you know of another repository that exhibits the same problem that I can fully clone? |
@bording ah yes, sorry that submodule is private - it contains our private keys etc. The build instructions cover it, you need to do a |
Regarding reproing the crash, are you running in |
It'd be interesting to see what the C stack trace looks like, but I certainly suspect the repository is being disposed and thus freed while we're in the middle of trying to run the status. It might need a sizeable repository in order for it to take long enough for GC to take effect. |
Often I would run it once and it would crash within 10 iterations. Just now I struggled a bit to get the crash. It seems to crash pretty soon or not at all. Maybe try restarting the app a few times? It did finally crash: I've got a crash |
I'm definitely running in release mode. I went ahead and re-cloned the repo and removed the script submodule, butI have not been able to see a single crash. I've run the app many times now, and it's working fine. @grokys @jcansdale I'm assuming you've got the script module actually checked out when you're running into the problem? Have you tried it with a clone of the repo without the script submodule? If the presence of script submodule isn't relevant to causing the crash, then there must be some other variable that isn't yet accounted for. What OS are you running on? What version of the .NET Framework do you have installed, and which one are you targeting? Are running the app as 32 or 64 bit? I'm not sure any of that would make a difference, but I'm trying to think of what else it could be. @jcansdale The dmp file might be helpful, if you've got a way to share it. |
Here's a stack trace of one of the times it crashed. The top points to https://github.com/libgit2/libgit2/blob/a5cf255b471ad7113247d552d5695db0cb720882/src/attrcache.c#L182 which is a call to the inlined https://github.com/libgit2/libgit2/blob/a5cf255b471ad7113247d552d5695db0cb720882/src/attrcache.c#L27-L36 which just looks up the entry in a dictionary. It's still trying to look up address 0x14 which keeps looking like we cleaned up the repo, or at least the cache midway and we're trying to access the struct at The crash is reproducing by opening the Avalonia PR page in GHfVS and clicking around a few different ones.
|
I've been following the trail for all those libgit2sharp crashes I'm experiencing (I'm trying to use it from inside Unity, with random crashes all the time, most notably on domain reload but also in random situtations), which led me here. Has there ever been a consensus on what causes this? Is the workaround (two years later) to still use 0.23? The same is still happening on 0.26.1 with libgit2 2.0.298, and also latest preview versions. |
Iirc, it was caused by objects being collected before native methods return. This was counter intuative as a developer used to managed code. The fix was to always use using blocks for objects that are disposable (most libgit2sharp types). I hope that helps. It was a while ago we last faced this issue. |
I was able to pinpoint a couple more cases where that happened and have something that feels "kinda stable" right now. Same as you, I went to "using() everywhere" (I was caching the repository object before). Additionally, the bug that took me the longest to find was that inside the using(), I was using LINQ queries and forgot about deferred execution - when execution was actually happening at some random other point in time, the repository object was long gone and I got those native crashes. Forcing execution inside the using() block with ToList() solved that part of the issue. |
Yup, I think we were caching repository objects as well. It gets particularly confusing when Debug builds work, but Release builds don't! |
And stepping through with debugger also always works - seems to prevent the repository object GC as well... |
I've the same problem with 0.26 and 0.27 preview:
Just seen #1886 ... my issue also started after an update of VS2019 to 16.10.1. (This update also contained the latest .NET 5 SDK 5.0.7) |
We've noticed that the GitHub Extension for Visual Studio has been crashing with an
AccessViolationException
. This often happens when a user previews a PR and the extension callsRetrieveStatus
. This exception occurs randomly and is thrown by thegit_status_list_new
method.This exception is most easily reproduced using
0.24
or0.25.0-preview-0033
, but it does also happen with0.23.1
(but I haven't seen it using the repro below).How to reproduce
https://github.com/github/VisualStudio.git
toC:\source\github.com\github\VisualStudio\
.Release
configuration using LibGit2Sharpv0.24
:I tried to create a standalone app, but wasn't able to trigger it with a very simple repo. I'm using the
github\VisualStudio
one because I'm most familiar it, but it does this with many others as well.What to expect
The most common exception is as follows:
But sometimes
NotFoundExceptions
are thrown as well.Related issues / PRs
The text was updated successfully, but these errors were encountered: