-
Notifications
You must be signed in to change notification settings - Fork 5k
Exception when using LibGit2Sharp with .NET 9 preview 6 #104872
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
It's probably caused by libgit2sharp having a gchole here in the implicit operator on a class that has a finalizer which just returns a pointer that doesn't keep the class alive. In general as far as I've seen, the libgit2sharp sharp bindings were not great, while looking around at the code here I for example noticed another bug where their EncodingMarshaller doesn't properly account for encodings that uses more than 1B for null terminator. |
There were other AV-like complains on libgit2sharp e.g. #101479 (comment), #53990 and, probably, #102313. From a quick look it indeed feels like it could be related to finalizer and lack of SafeHandle usage. |
I'm aware of multiple issues with libgit2sharp in the past :( As this issue only occurs with .NET 9, I was wondering if there is a regression in .NET 9. If this is not the case, feel free to close the issue. |
If it is what we think it is (here), then it could be just an internal change in GC or JIT that exposes a bug in the library (or exposes it more often now) |
Although, it's possible something is wrong with the custom marshaller over [LibraryImport(libgit2, StringMarshalling = StringMarshalling.Utf8)]
internal static unsafe partial int git_blob_create_from_stream(
out IntPtr stream,
git_repository* repositoryPtr,
string hintpath); |
Tagging subscribers to this area: @dotnet/interop-contrib |
I'm going to close this in favor of the LibGit2Sharp maintainers fixing the lifetime management in libgit2sharp as mentioned above. |
Description
When running the repro code with .NET 9 preview 6, the execution stops. The same code runs well with .NET 8.
I can also reproduce the error using the daily build (9.0.100-preview.7.24362.28 (a2689ba4aa))
Note: When running the code in my original project, VS reports an
System.ExecutionEngineException
exception. However, VS doesn't show this error in the repro code, but it still fail.Reproduction Steps
Expected behavior
The code works on .NET 8 and .NET 9
Actual behavior
Regression?
Yes as it works on .NET 8
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: