Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.
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.
Created attachment 25348 [details] Simple test case source file FieldInfo.GetValue() fails to return correct reference. Results Mono/Linux: Field:"IntField" is type of:System.Int32 Field:"StringField" is type of:TestNamespace.TestClass Results .NET/Windows Field:"IntField" is type of:System.Int32 Field:"StringField" is type of:System.String
Can reproduce this on mono master.
We end up in a call in `mono_field_get_value_object_checked (domain, field, obj, error)` with obj a TransparentProxy. After that we call `mono_field_get_value (obj, field, &o)` which is essentially a memcpy from some random offset inside the transparent proxy. We instead need a call to `mono_load_remote_field_new_checked`. A few more observations: 1. It doesn't do anything sensible with the valuetype field either, it just so happens that the valuetype codepath boxes up whatever bits happen to be there into a boxed integer - the boxing code doesn't care that the value is junk, it'll still be a System.Int32 2. If you add a few more reference fields you can get some null pointer exceptions because the object layout of a transparent proxy has a couple of null fields later on. 3. The setter code is likely broken too.
This reproduces with mono versions back to at least 4.6.2
Fixed on mono master https://github.com/mono/mono/commit/a9e1c60a63ee829de3a81e49e8374573c3cbfca8 Fixed on mono 2017-10 https://github.com/mono/mono/commit/bba2a47492fa75f7663020b7831bd3a9fa10cbd2