[Mono-list] exception handling problem

Varga Zoltan vargaz@freemail.hu
Tue, 21 Jan 2003 20:37:08 +0100 (CET)


--0-1804289383-1043177828=:69872
Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-2


                                          Hi,

  The current JIT sometimes miscompiles exception handling
code. Here
is an example:

	catch [mscorlib]System.Exception {
	  	call void class [mscorlib]System.Console::WriteLine()
	  	call void class [mscorlib]System.Console::WriteLine(object)
	  	leave IL_0030
        }

From this, the JIT creates the following tree:

        (CALL_VOID NOP ADDR_G)
        (ARG_I4 EXCEPTION)
        (CALL_VOID NOP ADDR_G)
        RETHROW_ABORT
        BR

As can be seen above, the first call precedes the EXCEPTION
node,
which means the call will corrupt the exception object
stored in ECX.

I attached a more complete testcase for the problem.

                               bye

                                    Zoltan
--0-1804289383-1043177828=:69872
Content-Type: APPLICATION/octet-stream; name="bug-catch.il"
Content-Disposition: attachment; filename="bug-catch.il"

.assembly extern mscorlib
{
  .ver 1:0:3300:0
}

.assembly 'bug-catch'
{
  .hash algorithm 0x00008004
  .ver  0:0:0:0
}
  .class private auto ansi beforefieldinit Foo
  	extends [mscorlib]System.Object
  {

    .method public hidebysig  specialname  rtspecialname 
           instance default void .ctor()  cil managed 
    {
	.maxstack 8
	IL_0000: ldarg.0 
	IL_0001: call instance void valuetype [mscorlib]System.Object::.ctor()
	IL_0006: ret 
    }

    .method public static 
           default void Main()  cil managed 
    {
	.entrypoint
	.maxstack 5
	.locals init (
		class [mscorlib]System.Exception	V_0)
	.try { // 0
	  IL_0000: ldstr "EX"
	  IL_0005: newobj instance void class [mscorlib]System.Exception::.ctor(string)
	  IL_000a: throw 
	  IL_000b: leave IL_0030

	} // end .try 0
	catch [mscorlib]System.Exception {
	  	call void class [mscorlib]System.Console::WriteLine()
	  	call void class [mscorlib]System.Console::WriteLine(object)
	  	leave IL_0030
	}
	IL_0030: ret 
    }

  } // end of type Foo


--0-1804289383-1043177828=:69872--