[Mono-devel-list] a jit bug?

Mohammad DAMT md at mt.web.id
Thu Dec 4 11:01:36 EST 2003


The attached files can be compiled by mcs, but the jit will abort with
message as described below. However it can be run by mint.

config: mono+mcs from cvs today

[mdamt at gordon tmp]$ mcs test.cs
Compilation succeeded
[mdamt at gordon tmp]$ mint test.exe
Sada
[mdamt at gordon tmp]$ mono test.exe
 
** ERROR **: Invalid IL code at IL0020 in
Weirdo.Weirdo:ProblematicSwitch (string): IL_0020: br        IL_005c
 
 
aborting...
Aborted

and this is the il codes:
    // method line 2
    .method private
           instance default string 'ProblematicSwitch' (string 'param') 
cil managed
    {
        .param [1]
        // Method begins at RVA 0x20f4
        // Code size 92 (0x5c)
        .maxstack 5
        .locals init (
                string  V_0)
        IL_0000:  ldarg.1
        IL_0001:  stloc.0
        IL_0002:  ldloc.0
        IL_0003:  brfalse IL_0051
 
        IL_0008:  ldloc.0
        IL_0009:  call string valuetype
[mscorlib]'System.String'::'IsInterned'(string)
        IL_000e:  stloc.0
        IL_000f:  ldloc.0
        IL_0010:  ldstr "sada"
        IL_0015:  bne.un IL_0025
 
        IL_001a:  ldstr "Sada"
        IL_001f:  ret
        IL_0020:  br IL_005c
 
        IL_0025:  ldloc.0
        IL_0026:  ldstr "dua"
        IL_002b:  bne.un IL_003b
 
        IL_0030:  ldstr "Dua"
        IL_0035:  ret
        IL_0036:  br IL_005c
 
        IL_003b:  ldloc.0
        IL_003c:  ldstr "tolu"
        IL_0041:  bne.un IL_0051
 
        IL_0046:  ldstr "Tolu"
        IL_004b:  ret
        IL_004c:  br IL_005c
 
        IL_0051:  ldstr ""
        IL_0056:  ret
        IL_0057:  br IL_005c
 
    } // end of method Weirdo::instance default string
'ProblematicSwitch' (string 'param')

-------------- next part --------------
using System;

namespace Weirdo {
	class Weirdo 
	{
		Weirdo ()
		{
		}

		// this one will abort mono execution with message something like this:
		// ** ERROR **: Invalid IL code at IL0020 in Weirdo.Weirdo:ProblematicSwitch (string): IL_0020: br        IL_005c
		string ProblematicSwitch (string param)
		{
			switch (param) {
				case "sada":
					return "Sada";
					break;
				case "dua":
					return "Dua";
					break;
				case "tolu":
					return "Tolu";
					break;
				default:
					return "";  // this is the suspect, break after the return
					break;
			}
		}

		string WorkingSwitch (string param)
		{
			switch (param) {
				case "sada":
					return "Sada";
					break;
				case "dua":
					return "Dua";
					break;
				case "tolu":
					return "Tolu";
					break;
				default:
					break;
			}
			return "";
		}

		static void Main ()
		{
			Weirdo w = new Weirdo ();
			// uncomment one of these two:
			Console.WriteLine (w.ProblematicSwitch ("sada"));
			//Console.WriteLine (w.WorkingSwitch ("sada"));
		}
	}
}


More information about the Mono-devel-list mailing list