|Summary:||Mono crashes when marshalling fixed arrays|
|Product:||[Mono] Runtime||Reporter:||Dimitar Dobrev <dpldobrev>|
|Severity:||normal||CC:||joao.matos, mono-bugs+mono, mono-bugs+runtime, vargaz|
|Tags:||Is this bug a regression?:||---|
|Last known good build:|
Description Dimitar Dobrev 2015-09-02 12:16:10 UTC
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 .
Comment 1 João Matos 2015-09-02 12:35:48 UTC
Worked around on CppSharp: https://github.com/mono/CppSharp/commit/6623161200e039c70254fec8371241e7370a49ca
Comment 2 Zoltan Varga 2015-09-04 00:59:43 UTC
Does it also fail if the StructLayout and the FieldOffset attributes are removed ? They are not really needed.
Comment 3 Dimitar Dobrev 2015-09-04 06:55:29 UTC
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?".
Comment 4 Zoltan Varga 2015-09-09 17:27:19 UTC
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.
Comment 5 Dimitar Dobrev 2015-09-10 03:57:35 UTC
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.
Comment 6 Dimitar Dobrev 2016-08-24 16:27:48 UTC
It has been almost a year and this obvious bug has received no attention whatsoever. When is it going to be fixed?
Comment 7 Zoltan Varga 2016-08-25 18:45:18 UTC
Fixed in master 20b49905f26fac15338aa2862b119de9026cb4f7.
Comment 8 Dimitar Dobrev 2016-08-25 19:06:29 UTC
So it was a bug after all. :) Thanks for the fix.