[Mono-bugs] [Bug 369173] New: TypeLoad exception and runtime crash when emitting type

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Mar 11 09:43:31 EDT 2008


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


           Summary: TypeLoad exception and runtime crash when emitting type
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: msafar at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


1. compile following program using gmcs

using System;

using System.Reflection;

using System.Reflection.Emit;



public class C

{

        static void Emit (Type t)

        {

         /// INITIAL ASSEMBLY CREATION

         AssemblyName name = new AssemblyName();

         name.Name = "o";

         AssemblyBuilder builder =

            AppDomain.CurrentDomain.DefineDynamicAssembly(name,

                    AssemblyBuilderAccess.Save);

         ModuleBuilder mb = builder.DefineDynamicModule("out", "bla.dll");

         ///////////



         TypeBuilder ta = mb.DefineType("MyEnum", TypeAttributes.Sealed, t,
null);

         Type quxc = ta.CreateType();

         ta.CreateType ();

         builder.Save("bla.dll");

     }





        public static void Main (string[] args)

        {

                Assembly a = Assembly.LoadFile (args[0]);
                Console.WriteLine (a.FullName);

                Type t = a.GetType ("System.Enum");

                Print (t);

                Emit (t);

        }



        static void Print (Type t)

        {

                Console.WriteLine (t.FullName);

                Console.WriteLine (t.Assembly.FullName);

        }

}

2. Run it using enclosed test libraries

Test 1: test.exe lib1.dll

Expected Output: No error and correctly emitted bla.dll
Actual Output:


lib1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Stacktrace:

  at (wrapper managed-to-native) System.Reflection.Assembly.InternalGetType
(System.Reflection.Module,string,bool,bool) <0x00004>
  at (wrapper managed-to-native) System.Reflection.Assembly.InternalGetType
(System.Reflection.Module,string,bool,bool) <0xffffffff>
  at System.Reflection.Assembly.GetType (string,bool,bool) <0x0001f>
  at System.Reflection.Assembly.GetType (string) <0x00014>
  at C.Main (string[]) <0x00043>
  at (wrapper runtime-invoke) C.runtime_invoke_void_string[]
(object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono [0x8180c1e]
        mono [0x807f971]
        [0xffffe440]
        mono(mono_class_init+0x158) [0x809ea48]
        mono [0x80f4d63]
        mono [0x80f4fec]
        mono [0x810fe91]
        [0xb7949e07]
        [0xb7949da0]
        [0xb7949d6d]
        [0xb794425c]
        [0xb79441b3]
        mono(mono_runtime_exec_main+0xbb) [0x80b6adb]
        mono(mono_runtime_run_main+0x1ba) [0x80b7eea]
        mono(mono_main+0x102f) [0x805b9ef]
        mono [0x805a4b2]
        /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7d34050]
        mono [0x805a421]

Debug info from gdb:

Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1210988848 (LWP 31530)]
[New Thread -1220809840 (LWP 31532)]
[New Thread -1215022192 (LWP 31531)]
0xffffe410 in __kernel_vsyscall ()
  3 Thread -1215022192 (LWP 31531)  0xffffe410 in __kernel_vsyscall ()
  2 Thread -1220809840 (LWP 31532)  0xffffe410 in __kernel_vsyscall ()
  1 Thread -1210988848 (LWP 31530)  0xffffe410 in __kernel_vsyscall ()

Thread 3 (Thread -1215022192 (LWP 31531)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e999f6 in ?? () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x08117f01 in collection_thread (unused=0x0) at collection.c:34
#3  0xb7e9246b in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#4  0xb7df16de in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 2 (Thread -1220809840 (LWP 31532)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e96676 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0812613f in timedwait_signal_poll_cond (cond=0xb78b81dc, 
    mutex=0xb78b81c4, timeout=0x0, alertable=0) at handles.c:1443
#3  0x08128bdf in _wapi_handle_timedwait_signal_handle (handle=0x404, 
    timeout=0x0, alertable=0) at handles.c:1523
#4  0x08128c5c in _wapi_handle_wait_signal_handle (handle=0x404, alertable=0)
    at handles.c:1483
#5  0x0812b9ef in WaitForSingleObjectEx (handle=0x404, timeout=4294967295, 
    alertable=0) at wait.c:200
#6  0x08116afa in finalizer_thread (unused=0x0) at gc.c:894
#7  0x080e920f in start_wrapper (data=0x8273730) at threads.c:590
#8  0x081242f2 in thread_start_routine (args=0xb7769b80) at threads.c:282
#9  0x0813e215 in GC_start_routine (arg=0x26f40) at pthread_support.c:1369
#10 0xb7e9246b in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#11 0xb7df16de in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 1 (Thread -1210988848 (LWP 31530)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7dea2a1 in select () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7f13780 in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
#3  0xb7f13b4c in g_spawn_command_line_sync () from /usr/lib/libglib-2.0.so.0
#4  0x08180cb9 in mono_handle_native_sigsegv (signal=11, ctx=0xb7becd0c)
    at mini-exceptions.c:1089
#5  0x0807f971 in mono_arch_handle_altstack_exception (sigctx=0xb7becd0c, 
    fault_addr=0x19, stack_ovf=0) at exceptions-x86.c:855
#6  <signal handler called>
#7  mono_class_init (class=0x82a25b4) at class.c:3596
#8  0x0809ea48 in mono_class_init (class=0x82a24ec) at class.c:3441
#9  0x080f4d63 in mono_reflection_get_type_internal (rootimage=0x82a6c18, 
    image=<value optimized out>, info=0xbf9e25e0, ignorecase=0)
    at reflection.c:6487
#10 0x080f4fec in mono_reflection_get_type_with_rootimage (
    rootimage=0x82a6c18, image=0x82db264, info=0xbf9e25e0, ignorecase=0, 
    type_resolve=0xbf9e25dc) at reflection.c:6594
#11 0x0810fe91 in ves_icall_System_Reflection_Assembly_InternalGetType (
    assembly=0x30f90, module=0x0, name=0x41fa0, throwOnError=0 '\0', 
    ignoreCase=0 '\0') at icall.c:4086
#12 0xb7949e07 in ?? ()
#13 0x00030f90 in ?? ()
#14 0x00000000 in ?? ()
#0  0xffffe410 in __kernel_vsyscall ()


=================================================================
Got a SIGSEGV 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 (core dumped)


Test 2: test.exe lib2.dll

Expected Output: No error and correctly emitted bla.dll

Actual Output:

lib2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
System.Enum
lib2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

Unhandled Exception: System.TypeLoadException: Could not load type 'MyEnum'.
  at (wrapper managed-to-native)
System.Reflection.Emit.TypeBuilder:create_runtime_class
(System.Reflection.Emit.TypeBuilder)
  at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] 
  at C.Emit (System.Type t) [0x00000] 
  at C.Main (System.String[] args) [0x00000] 
marek at m-6400:~/svn/mcs/mcs/lupus$ mono test-1000.exe lib1.dll 
lib1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Stacktrace:

  at (wrapper managed-to-native) System.Reflection.Assembly.InternalGetType
(System.Reflection.Module,string,bool,bool) <0x00004>
  at (wrapper managed-to-native) System.Reflection.Assembly.InternalGetType
(System.Reflection.Module,string,bool,bool) <0xffffffff>
  at System.Reflection.Assembly.GetType (string,bool,bool) <0x0001f>
  at System.Reflection.Assembly.GetType (string) <0x00014>
  at C.Main (string[]) <0x00043>
  at (wrapper runtime-invoke) C.runtime_invoke_void_string[]
(object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono [0x8180c1e]
        mono [0x807f971]
        [0xffffe440]
        mono(mono_class_init+0x158) [0x809ea48]
        mono [0x80f4d63]
        mono [0x80f4fec]
        mono [0x810fe91]
        [0xb78c5e07]
        [0xb78c5da0]
        [0xb78c5d6d]
        [0xb78c025c]
        [0xb78c01b3]
        mono(mono_runtime_exec_main+0xbb) [0x80b6adb]
        mono(mono_runtime_run_main+0x1ba) [0x80b7eea]
        mono(mono_main+0x102f) [0x805b9ef]
        mono [0x805a4b2]
        /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0) [0xb7cb0050]
        mono [0x805a421]

Debug info from gdb:

Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -1211529520 (LWP 31180)]
[New Thread -1221350512 (LWP 31182)]
[New Thread -1215562864 (LWP 31181)]
0xffffe410 in __kernel_vsyscall ()
  3 Thread -1215562864 (LWP 31181)  0xffffe410 in __kernel_vsyscall ()
  2 Thread -1221350512 (LWP 31182)  0xffffe410 in __kernel_vsyscall ()
  1 Thread -1211529520 (LWP 31180)  0xffffe410 in __kernel_vsyscall ()

Thread 3 (Thread -1215562864 (LWP 31181)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e159f6 in ?? () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x08117f01 in collection_thread (unused=0x0) at collection.c:34
#3  0xb7e0e46b in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#4  0xb7d6d6de in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 2 (Thread -1221350512 (LWP 31182)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e12676 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0812613f in timedwait_signal_poll_cond (cond=0xb78341dc, 
    mutex=0xb78341c4, timeout=0x0, alertable=0) at handles.c:1443
#3  0x08128bdf in _wapi_handle_timedwait_signal_handle (handle=0x404, 
    timeout=0x0, alertable=0) at handles.c:1523
#4  0x08128c5c in _wapi_handle_wait_signal_handle (handle=0x404, alertable=0)
    at handles.c:1483
#5  0x0812b9ef in WaitForSingleObjectEx (handle=0x404, timeout=4294967295, 
    alertable=0) at wait.c:200
#6  0x08116afa in finalizer_thread (unused=0x0) at gc.c:894
#7  0x080e920f in start_wrapper (data=0x8273730) at threads.c:590
#8  0x081242f2 in thread_start_routine (args=0xb76e57d8) at threads.c:282
#9  0x0813e215 in GC_start_routine (arg=0x26f40) at pthread_support.c:1369
#10 0xb7e0e46b in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#11 0xb7d6d6de in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 1 (Thread -1211529520 (LWP 31180)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7d2cf69 in fork () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7e17874 in fork () from /lib/tls/i686/cmov/libpthread.so.0
#3  0xb7e8eab9 in ?? () from /usr/lib/libglib-2.0.so.0
#4  0x00000010 in ?? ()
#5  0x00000010 in ?? ()
#6  0x082c0a50 in ?? ()
#7  0x082c0aa8 in ?? ()
#8  0x082c0aa8 in ?? ()
#9  0xe96258b8 in ?? ()
#10 0xb7d04071 in ?? () from /lib/tls/i686/cmov/libc.so.6
#11 0x00000010 in ?? ()
#12 0x00000010 in ?? ()
#13 0x00000010 in ?? ()
#14 0xb7b681a4 in ?? ()
#15 0xb7d05fc0 in malloc () from /lib/tls/i686/cmov/libc.so.6
#16 0xb7e8f6ab in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
#17 0xb7e8fb4c in g_spawn_command_line_sync () from /usr/lib/libglib-2.0.so.0
#18 0x08180cb9 in mono_handle_native_sigsegv (signal=11, ctx=0xb7b68d0c)
    at mini-exceptions.c:1089
#19 0x0807f971 in mono_arch_handle_altstack_exception (sigctx=0xb7b68d0c, 
    fault_addr=0x19, stack_ovf=0) at exceptions-x86.c:855
#20 <signal handler called>
#21 mono_class_init (class=0x82a25b4) at class.c:3596
#22 0x0809ea48 in mono_class_init (class=0x82a24ec) at class.c:3441
#23 0x080f4d63 in mono_reflection_get_type_internal (rootimage=0x82a6c18, 
    image=<value optimized out>, info=0xbfdc99c0, ignorecase=0)
    at reflection.c:6487
#24 0x080f4fec in mono_reflection_get_type_with_rootimage (
    rootimage=0x82a6c18, image=0x82db264, info=0xbfdc99c0, ignorecase=0, 
    type_resolve=0xbfdc99bc) at reflection.c:6594
#25 0x0810fe91 in ves_icall_System_Reflection_Assembly_InternalGetType (
    assembly=0x30f90, module=0x0, name=0x41fa0, throwOnError=0 '\0', 
    ignoreCase=0 '\0') at icall.c:4086
#26 0xb78c5e07 in ?? ()
#27 0x00030f90 in ?? ()
#28 0x00000000 in ?? ()
#0  0xffffe410 in __kernel_vsyscall ()


=================================================================
Got a SIGSEGV 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 (core dumped)


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


More information about the mono-bugs mailing list