Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 14349 [details]
CIL code of the failing program
I am one of the authors of a prototype LISP to CLI compiler https://github.com/codingteam/naggum
I am trying to compile the following line: (System.Console.WriteLine "ok")
(No, you do not have to mess with that custom compiler, I've tested the bug with the CIL code attached.)
I've compiled CIL with the following command:
> ilasm Program.il
After that I've executed it on .NET and Mono with the following results:
> mono Program.exe
System.InvalidProgramException: Invalid IL code in Program:Main (): IL_000b: ret
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in Program:Main (): IL_000b: ret
I am using the latest available Mono for Windows:
> mono --version
Mono JIT compiler version 4.2.1 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
Notification: Thread + polling
LLVM: supported, not enabled.
I've tried to decompile this program with ilspy and got this weird result:
public static int Main()
Yes, that's very strange that null is returned from the int method, but again: official CLR (I use 4.6.1) have no problems executing that.
Program.il file is attached. The bug is reproducible on Windows with Mono 4.2.1 and also on Travis (it uses 4.2.1 also), see the report here: https://travis-ci.org/codingteam/naggum#L1127
You're generating invalid IL. And for that the expected implementation behavior is to fail with the above exception.
dotnet, for some reason, gives large amplitude of what's the acceptable IR beyond the spec.
Given that those loosen restrictions aren not specified nor is the expected behavior, we side with not accepting such IL.
My suggestion is that you stick with generating verifiable code and passes peverify.
For a reference of what's ok or not, see the ECMA-335 spec: http://www.ecma-international.org/publications/standards/Ecma-335.htm