Skip to content

Test: ildasm/ilasm failure with 'loopEH' testcase #5778

@myungjoo

Description

@myungjoo

The loopEH test case of CoreCLR, tests/src/JIT/jit64/eh/basics/loopEH.cs, has no issue of exception handling at ARM/Linux IF we directly execute the resulting loopEH.exe: it returns 100 as expected.

However, as loopEH.sh suggests, if we apply ildasm to loopEH.exe and try ilasm to the resulting assembly, we get the following error:

bash-3.2# ./ilasm -out=test.exe loopEH.dasm.il 

Microsoft (R) .NET Framework IL Assembler.  Version 4.5.22220.0
C
Assembling 'loopEH.dasm.il'  to EXE --> 'test.exe'
Source file is ANSI

Assembled method Program::Main
loopEH.dasm.il(152) : error : Unable to find forward reference label 'IL_012a' called from PC=59
loopEH.dasm.il(152) : error : Method 'Test' compilation failed.
Assembled method Program::.ctor

***** FAILURE ***** 
bash-3.2# 

This is a legit complaint from ilasm because the given disasm does have undefined label IL_012a. If I compile loopEH.cs in Linux/ARM with Roslyn and the today's mscorlib.dll and coreclr, it shows equivalent disasm that has the same error from ilasm.

This appears to be a BUG in ildasm, not CoreCLR's JIT or EH functionality.

bash-3.2# cat loopEH.dasm.il 

//  Microsoft (R) .NET Framework IL Disassembler.  Version 4.5.22220.0



// Metadata version: v4.0.30319
.assembly extern System.Runtime
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:1:0:0
}
.assembly extern System.Collections
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:0:0:0
}
.assembly extern System.Console
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:0:0:0
}
.assembly loopEH
{
  .custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) 
  .custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78   // ....T..WrapNonEx
                                                                                                                   63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 )       // ceptionThrows.

  // --- The following custom attribute is added automatically, do not uncomment -------
  //  .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 ) 

  .publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00   // .$..............
                00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00   // .$..RSA1........
                07 D1 FA 57 C4 AE D9 F0 A3 2E 84 AA 0F AE FD 0D   // ...W............
                E9 E8 FD 6A EC 8F 87 FB 03 76 6C 83 4C 99 92 1E   // ...j.....vl.L...
                B2 3B E7 9A D9 D5 DC C1 DD 9A D2 36 13 21 02 90   // .;.........6.!..
                0B 72 3C F9 80 95 7F C4 E1 77 10 8F C6 07 77 4F   // .r<......w....wO
                29 E8 32 0E 92 EA 05 EC E4 E8 21 C0 A5 EF E8 F1   // ).2.......!.....
                64 5C 4C 0C 93 C1 AB 99 28 5D 62 2C AA 65 2C 1D   // d\L.....(]b,.e,.
                FA D6 3D 74 5D 6F 2D E5 F1 7E 5E AF 0F C4 96 3D   // ..=t]o-..~^....=
                26 1C 8A 12 43 65 18 20 6D C0 93 34 4D 5A D2 93 ) // &...Ce. m..4MZ..
  .hash algorithm 0x00008004
  .ver 0:0:0:0
}
.module loopEH.exe
// MVID: {f6bff5b9-562d-4aa0-a6c3-624df3302aa7}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003       // WINDOWS_CUI
.corflags 0x00000009    //  ILONLY
// Image base: 0xB6FD5000


// =============== CLASS MEMBERS DECLARATION ===================

.class private auto ansi beforefieldinit Program
       extends [System.Runtime]System.Object
{
  .method private hidebysig static int32 
          Main(string[] args) cil managed
  {
    .entrypoint
    // Code size       12 (0xc)
    .maxstack  8
    IL_0000:  ldnull
    IL_0001:  ldnull
    IL_0002:  ldnull
    IL_0003:  ldc.i4.0
    IL_0004:  ldc.i4.1
    IL_0005:  conv.i8
    IL_0006:  call       int32 Program::Test(class [System.Collections]System.Collections.Generic.List`1<string>,
                                             class [System.Collections]System.Collections.Generic.List`1<string>,
                                             string,
                                             int32,
                                             int64)
    IL_000b:  ret
  } // end of method Program::Main

  .method public hidebysig static int32  Test(class [System.Collections]System.Collections.Generic.List`1<string> liste,
                                              class [System.Collections]System.Collections.Generic.List`1<string> unused1,
                                              string unused2,
                                              int32 unused3,
                                              int64 p_lFirstId) cil managed
  {
    // Code size       119 (0x77)
    .maxstack  2
    .locals init (class [System.Runtime]System.Text.StringBuilder V_0,
             int32 V_1,
             valuetype [System.Collections]System.Collections.Generic.List`1/Enumerator<string> V_2,
             string V_3)
    IL_0000:  newobj     instance void class [System.Collections]System.Collections.Generic.List`1<string>::.ctor()
    IL_0005:  starg.s    liste
    IL_0007:  newobj     instance void [System.Runtime]System.Text.StringBuilder::.ctor()
    IL_000c:  stloc.0
    IL_000d:  ldc.i4.0
    IL_000e:  stloc.1
    IL_000f:  br.s       IL_004f

    IL_0011:  ldloc.0
    IL_0012:  ldarg.s    p_lFirstId
    IL_0014:  callvirt   instance class [System.Runtime]System.Text.StringBuilder [System.Runtime]System.Text.StringBuilder::Append(int64)
    IL_0019:  pop
    IL_001a:  ldarg.s    p_lFirstId
    IL_001c:  ldc.i4.1
    IL_001d:  conv.i8
    IL_001e:  add
    IL_001f:  starg.s    p_lFirstId
    IL_0021:  ldarg.0
    IL_0022:  callvirt   instance valuetype [System.Collections]System.Collections.Generic.List`1/Enumerator<!0> class [System.Collections]System.Collections.Generic.List`1<string>::GetEnumerator()
    IL_0027:  stloc.2
    IL_0028:  br.s       IL_0032

    IL_002a:  ldloca.s   V_2
    IL_002c:  call       instance !0 valuetype [System.Collections]System.Collections.Generic.List`1/Enumerator<string>::get_Current()
    IL_0031:  stloc.3
    IL_0032:  ldloca.s   V_2
    IL_0034:  call       instance bool valuetype [System.Collections]System.Collections.Generic.List`1/Enumerator<string>::MoveNext()
    IL_0039:  brtrue.s   IL_012a

    IL_003b:  leave.s    IL_004b

    IL_003d:  ldloca.s   V_2
    IL_003f:  constrained. valuetype [System.Collections]System.Collections.Generic.List`1/Enumerator<string>
    IL_0045:  callvirt   instance void [System.Runtime]System.IDisposable::Dispose()
    IL_004a:  endfinally
    IL_004b:  ldloc.1
    IL_004c:  ldc.i4.1
    IL_004d:  add
    IL_004e:  stloc.1
    IL_004f:  ldloc.1
    IL_0050:  ldc.i4.s   10
    IL_0052:  blt.s      IL_0111

    IL_0054:  ldloc.0
    IL_0055:  callvirt   instance string [System.Runtime]System.Object::ToString()
    IL_005a:  call       void [System.Console]System.Console::WriteLine(string)
    IL_005f:  ldloc.0
    IL_0060:  callvirt   instance string [System.Runtime]System.Object::ToString()
    IL_0065:  ldstr      "12345678910"
    IL_006a:  call       bool [System.Runtime]System.String::op_Equality(string,
                                                                         string)
    IL_006f:  brfalse.s  IL_0074

    IL_0071:  ldc.i4.s   100
    IL_0073:  ret

    IL_0074:  ldc.i4.s   101
    IL_0076:  ret
    IL_0077:  
    // Exception count 1
    .try IL_0028 to IL_003d finally handler IL_003d to IL_004b
  } // end of method Program::Test

  .method public hidebysig specialname rtspecialname 
          instance void  .ctor() cil managed
  {
    // Code size       7 (0x7)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  call       instance void [System.Runtime]System.Object::.ctor()
    IL_0006:  ret
  } // end of method Program::.ctor

} // end of class Program


// =============================================================

// *********** DISASSEMBLY COMPLETE ***********************

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions