Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Scenario in which the bug occur:
- ProgramA (.NET, C#) call LibraryA (C) through interop
- The function called in LibraryA takes a callback argument; the passed callback is defined in ProgramA
- One of the parameter sent by LibraryA to the callback is a `ref struct`
- The natively allocated memory backing one of the callback parameter is coming from a memory mapped region with the read only bit set
As the parameter of the callback is defined with [In, Out] (due to the ref keyword), this lead to a first Exception being thrown.
Applying only the [InAttribute] on the callback parameter solved the issue for the native .NET framework (successful execution).
However, a NullReferenceException occurs when running with Mono.
The bug can be seen here: https://github.com/libgit2/libgit2sharp/pull/487
The failing CI build (ran with Mono 2.10) can be seen here: https://travis-ci.org/libgit2/libgit2sharp/builds/10357001
If the problem was that mono tried to copy data back to the native representation even without an [Out] attribute, that is now fixed in mono master e682eceec3066a26afff333a7c1eb0e977ce7caa.