Open
Description
We've had a couple of bug reports against dotnet/runtime with rarely-reproduceable crashes coming from libgit2sharp. We believe that one possible reason could be an interop anti-pattern in Libgit2Object - void*/IntPtr
representation of a native handle that can be freed in finalizer. E.g. in this case the finalizer in Libgit2Object may end up calling native free here (and other overloads).
The reason why it's called an anti-pattern can be explained by a short repro in this issue: dotnet/runtime#103522 and a general solution is to use SafeHandle
for such handles. Also, see https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices
Reproduction steps
Expected behavior
Actual behavior
Version of LibGit2Sharp (release number or SHA1)
Operating system(s) tested; .NET runtime tested
Metadata
Metadata
Assignees
Labels
No labels