[Mono-dev] GIT code generator fails on some MSVC managed code

Paul Gofman gofmanp at gmail.com
Tue Feb 16 09:12:01 UTC 2016


    while running x64 mixed mode assemblies under Wine/Mono I came
through the problem that MSVC generated mixed IL code causes 'Invalid IL
code' exception under Mono. The same dll compiled in 32-bit does not
have such a problem. I've created a quick fix patch to
mono/mini/method-to-ir.c which fixes the issue for me and a bug which
now has a IL assembly test case and my patch (along with the initial
MSVC example & description of the problem):
    The last IL test case causes crash on native win32 and works under
    To summarize, what happens (as I see it): Windows allows much of
things mixing I8/PTR/I4 to pass compilation (for both 32/64), some of
them get native GPF under Win32. Mono is fully checking assemblies and
does not allow certain things to pass verifier (though if I do allow
I8/PTR mixing in verifier on x64 it works).

    I realize that the patch is probably not an upstream candidate in
its current form.
    The overall idea of arch-dependent assembly checks is probably not
so OK for Mono as assembly code is meant to be arch independent. Windows
might be following this principle but instead has less restrictive
checking allowing the compiled assembly natively crash when needed (and
managed code generator produces a different code for different arch). So
straightforward way to maintain compatibility with real MSVC managed
code under x64 is just allow such code to pass verifier.

    Maybe someone could push me in the right direction how this
compatibility issue can be correctly fixed in Mono? I could possibly
then make an appropriate patch and suggest it upstream.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20160216/14fcddd8/attachment.html>

More information about the Mono-devel-list mailing list