ILDASM incorrectly reconstruct EH clauses
ILDASM incorrectly reconstruct EH clauses when fTryInCode is true. A part of reason is due to sort which shouldn't be applied -- https://github.com/dotnet/coreclr/blob/master/src/ildasm/dis.cpp#L352 In addition, inserting ".try" clauses into source is not properly implemented. Note passing "-raweh" to just display raw EH tables at the end of method works correctly.
The followings are example assembly. Try ilasm followed by ildasm then EH clauses are reversed -- catching ArithmeticException followed by DivideByZeroException.
.class public _div {
.method public static int32 _div(int32,int32) {
.locals (class [mscorlib]System.Exception,int32)
.maxstack 3
try_start:
ldarg 0
ldarg 1
div
stloc.1
leave.s try_end
try_end:
ldloc.1
br END
arithmetic:
isinst [mscorlib]System.ArithmeticException
stloc 0
leave AEEnd
AEEnd:
ldloc 0
brfalse FAIL
ldc.i4 0xAE
br END
divbyzero:
isinst [mscorlib]System.DivideByZeroException
stloc 0
leave DBZEnd
DBZEnd:
ldloc 0
brfalse FAIL
ldc.i4 0xDB0E
br END
FAIL:
ldc.i4 0x00000000
br END
END:
ret
.try try_start to try_end catch [mscorlib]System.DivideByZeroException handler divbyzero to DBZEnd
.try try_start to try_end catch [mscorlib]System.ArithmeticException handler arithmetic to AEEnd
}
@kyulee1 If this is not a regression against desktop would you put it in the Future milestone?
Changed it for futher since it's the existing issue in desktop as well.
Not clear if this issue needs to be fixed. IL catch clause are processed in the order that they are specified and the first one that handled the Object kind handles the exception. It is illegal in C# to have multiple catch clauses that can handle the exception.
As noted the Desktop IL assembler also has this behavior and no one has filed a bug on this .