[Mono-bugs] [Bug 418381] New: Conversion from double to native int causes sigabort on IA64 Architecture

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Aug 19 11:47:33 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=418381


           Summary: Conversion from double to native int causes sigabort on
                    IA64 Architecture
           Product: Mono: Runtime
           Version: 1.2.6
          Platform: IA64
        OS/Version: SuSE Pro 9.2
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: JIT
        AssignedTo: lupus at novell.com
        ReportedBy: aabdullah at interactivesupercomputing.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Description of Problem:
The instruction conv.i is supposed to convert a value to a native int, and push
the native int onto the stack. This works fine on x86, and x86_64
architectures, but causes a sigabort on ia64 architectures.  The disassembled
code below will trigger the bug:

//float_to_int.asm
assembly extern mscorlib
{
  .ver 2:0:0:0
  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
}
assembly 'float_to_int'
{
  .custom instance void class
[mscorlib]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.

  .hash algorithm 0x00008004
  .ver  0:0:0:0
}
module float_to_int.exe // GUID = {FE7D55FE-0A34-4BC8-8E2E-97C17F170FEA}


namespace Foo.Bar
{
  .class public auto ansi beforefieldinit NativeIntTest
        extends [mscorlib]System.Object
  {

    // method line 1
    .method public hidebysig  specialname  rtspecialname
           instance default void .ctor ()  cil managed
    {
        // Method begins at RVA 0x20ec
        // Code size 7 (0x7)
        .maxstack 8
        IL_0000:  ldarg.0
        IL_0001:  call instance void object::.ctor()
        IL_0006:  ret
    } // end of method NativeIntTest::.ctor

    // method line 2
    .method public static  hidebysig
           default void Main (string[] args)  cil managed
    {
        // Method begins at RVA 0x20f4
        .entrypoint
        // Code size 36 (0x24)
        .maxstack 4
        .locals init (
                float64 V_0,
                int32   V_1)
        IL_0000:  ldc.r8 32.234200000000001
        IL_0009:  stloc.0
        IL_000a:  ldloc.0
        // Was conv.i4, modified to trigger bug
        IL_000b:  conv.i
        IL_000c:  stloc.1
        IL_000d:  ldstr "f {0} as a int is {1}"
        IL_0012:  ldloc.0
        IL_0013:  box [mscorlib]System.Double
        IL_0018:  ldloc.1
        IL_0019:  box [mscorlib]System.Int32
        IL_001e:  call void class [mscorlib]System.Console::WriteLine(string,
object, object)
        IL_0023:  ret
    } // end of method NativeIntTest::Main

  } // end of class Foo.Bar.NativeIntTest
}

Steps to reproduce the problem:
1. Use ilasm to compile float_to_int.asm
2. Run float_to_int.exe under mono 


Actual Results:
[aha at altix ~]$ mono float_to_int.exe 

** (float_to_int.exe:29928): WARNING **: unknown opcode float_conv_to_i in
mono_arch_output_basic_block()


** ERROR **: file mini-ia64.c: line 3124 (mono_arch_output_basic_block): should
not be reached
aborting...
Stacktrace:


Native stacktrace:

        mono [0x400000000029f8d0]
        [0xa0000000000107e0]
        [0xa000000000010641]
        /lib/tls/libc.so.6.1(gsignal+0x1b29b8) [0x20000000001f0690]
        /lib/tls/libc.so.6.1(abort+0x1b5108) [0x20000000001f2df0]
        /opt/gnome/lib/libglib-2.0.so.0(g_logv+0x96118) [0x20000000000d3e10]
        /opt/gnome/lib/libglib-2.0.so.0(g_log+0x965b8) [0x20000000000d42c0]
        mono [0x4000000000054d70]
        mono [0x4000000000238690]
        mono [0x400000000026f9b0]
        mono [0x4000000000271310]
        mono [0x4000000000271ec0]
        mono(mono_runtime_invoke+0x2000000000129798) [0x40000000001674b0]
        mono(mono_runtime_exec_main+0x2000000000132178) [0x400000000016fea0]
        mono(mono_runtime_run_main+0x20000000001330e8) [0x4000000000170e20]
        mono(mono_jit_exec+0x1ffffffffffdafe8) [0x4000000000018d30]
        mono(mono_main+0x1ffffffffffdc6f8) [0x400000000001a450]
        mono [0x4000000000018100]
        /lib/tls/libc.so.6.1(__libc_start_main+0x18bae8) [0x20000000001c9850]
        mono [0x4000000000017f40]

Debug info from gdb:



=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Aborted


Expected Results:
[aha at charm ~]$ mono float_to_int.exe
f 32.2342 as a int is 32


How often does this happen? 
Every time

Additional Information:

I think that the problem is in mini-ia64.c, near line 1796 there is a case
statement to handle conversions; however there are no cases to handle:
OP_FCONV_I
or
OP_FCONV_I8

I think that the following modifications may work, although I haven't had the
time to test it yet:

                // Added by aha to test fix for
                // native int conversions bug
                case OP_FCONV_TO_I:
                case OP_FCONV_TO_I8:
                // END MODIFICATION
                case OP_FCONV_TO_I4:
                case OP_FCONV_TO_I2:
                case OP_FCONV_TO_U2:
                case OP_FCONV_TO_I1:
                case OP_FCONV_TO_U1:
                        NEW_INS (cfg, ins, temp, OP_FCONV_TO_I8);
                        temp->sreg1 = ins->sreg1;
                        temp->dreg = ins->dreg;

                        switch (ins->opcode) {
                        case OP_FCONV_TO_I4:
                                ins->opcode = OP_SEXT_I4;
                                break;
                        case OP_FCONV_TO_I2:
                                ins->opcode = OP_SEXT_I2;
                                break;
                        case OP_FCONV_TO_U2:
                                ins->opcode = OP_ZEXT_I4;
                                break;
                        case OP_FCONV_TO_I1:
                                ins->opcode = OP_SEXT_I1;
                                break;
                        case OP_FCONV_TO_U1:
                                ins->opcode = OP_ZEXT_I1;
                                break;
                        // MODIFIED by onom to test fix for
                        // native int conversions bug
                        case OP_FCONV_TO_I:
                        case OP_FCONV_TO_I8:
                              break;
                        // END MODIFICATION
                        default:
                                g_assert_not_reached ();


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list