When marshalling a struct for a platform invocation, Mono crashes if the struct has a fixed array. Sample code and a complete stack trace can be found at https://gist.github.com/tritao/7e62c71ffe57d6bc326e .
Worked around on CppSharp: https://github.com/mono/CppSharp/commit/6623161200e039c70254fec8371241e7370a49ca
Does it also fail if the StructLayout and the FieldOffset attributes are removed ? They are not really needed.
It's obvious that this piece was cut down from a much larger one to make the test case as small as possible. It's just as obvious the larger one needs those attributes because nobody would add them just for fun. How should one feel about spending time to reduce the test case in order not to get the regular "please add a smaller test case otherwise we're going to do nothing about this", just to get "why is this test case so small?".
So the problem here is that that structure is not fully defined, it has holes in it, so the runtime doesn't know how to pass/receive it from native code, since the native ABI requires all struct members to be defined/consecutive.
The structure is actually correctly defined, that is, the bug is not in the example. First, it works with MS .NET. Second, it has an array of 3 elements x 4 bytes per int = 12 bytes, exactly the size specified in the layout.
It has been almost a year and this obvious bug has received no attention whatsoever. When is it going to be fixed?
Fixed in master 20b49905f26fac15338aa2862b119de9026cb4f7.
So it was a bug after all. :) Thanks for the fix.