Bug 8178 - Calling Marshal.ReadInt16 (object, int) crashes
Summary: Calling Marshal.ReadInt16 (object, int) crashes
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rodrigo Kumpera
URL:
Depends on:
Blocks:
 
Reported: 2012-11-02 10:59 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2012-11-08 12:03 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

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 Developer Community or GitHub 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.

Related Links:
Status:
RESOLVED FIXED

Description Rolf Bjarne Kvinge [MSFT] 2012-11-02 10:59:22 UTC
Add this to a MonoTouch project:

Console.WriteLine (System.Runtime.InteropServices.Marshal.ReadInt16 ((object)0, 0));

and it crashes with this:

* Assertion at ../../../../../mono/mono/metadata/reflection.c:9993, condition `System_Reflection_Emit_UnmanagedMarshalClass' not met

Full stack trace: https://gist.github.com/e4d5f07563e37c2ea05c

Note that this particular Marshal.ReadInt16 overload throws a NotImplementedException, so it's not trying to read null/random memory.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-11-02 10:59:58 UTC
Rodrigo, this looks like your area.
Comment 2 Rodrigo Kumpera 2012-11-02 11:05:06 UTC
Hmmm, not really, this might be a linker issue. The reflection code needs System.Reflection.Emit.UnmanagedMarshalClass and it's not finding it.

Or it might be a runtime on FULL_AOT_ISSUE. Need to dig further.
Comment 3 Zoltan Varga 2012-11-02 12:40:30 UTC
We probably need to whitelist that class in the linker.
Comment 4 Rodrigo Kumpera 2012-11-02 16:52:04 UTC
It's a corlib/runtime mess that needs some cleanup. I'm working on it. We still need the linker to whitelist MarshalAsAttribute as the runtime can't differentiate between a broken install and a linked away corlib.
Comment 5 Rodrigo Kumpera 2012-11-08 12:03:20 UTC
Fixed.