[Mono-bugs] [Bug 363447] New: AssemblyBuilder.GetCustomAttributes crashes if there' s an attribute defined with a type define in the same assembly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 20 17:43:25 EST 2008


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


           Summary: AssemblyBuilder.GetCustomAttributes crashes if there's
                    an attribute defined with a type define in the same
                    assembly
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: rkvinge at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Repro:

using System.Collections.Generic;
using System;
using System.Reflection;
using System.Reflection.Emit;

class test
{
        static void Main ()
        {
                AssemblyName name = new AssemblyName ();
                name.Name = "tester";
                AssemblyBuilder ab =
System.AppDomain.CurrentDomain.DefineDynamicAssembly(name,
System.Reflection.Emit.AssemblyBuilderAccess.Save, ".");
                ModuleBuilder mb = ab.DefineDynamicModule("tester",
"tester.dll", false);
                TypeBuilder tb = mb.DefineType ("T");
                tb.SetParent (typeof (System.Attribute));
                ConstructorBuilder ctor = tb.DefineDefaultConstructor
(MethodAttributes.Public);

                object [] o = new object [0];
                CustomAttributeBuilder cab = new CustomAttributeBuilder (ctor,
o);
                ab.SetCustomAttribute (cab);


                object cv = ab.GetCustomAttributes (true);

        }
}

result:

rolf at linux:~/test> gmcs test.cs && mono test.exe
test.cs(23,24): warning CS0219: The variable `cv' is assigned but its value is
never used
Compilation succeeded - 1 warning(s)
Stacktrace:

  at (wrapper managed-to-native)
System.MonoCustomAttrs.GetCustomAttributesInternal
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x00004>
  at (wrapper managed-to-native)
System.MonoCustomAttrs.GetCustomAttributesInternal
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0xffffffff>
  at System.MonoCustomAttrs.GetCustomAttributesBase
(System.Reflection.ICustomAttributeProvider,System.Type) <0x0001e>
  at System.MonoCustomAttrs.GetCustomAttributes
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x0001d>
  at System.MonoCustomAttrs.GetCustomAttributes
(System.Reflection.ICustomAttributeProvider,bool) <0x00086>
  at System.Reflection.Assembly.GetCustomAttributes (bool) <0x0000f>
  at test.Main () <0x000fa>
  at (wrapper runtime-invoke) System.Object.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono [0x817ed7f]
        mono [0x8081001]
        [0xffffe440]
        mono(mono_custom_attrs_construct+0x5b) [0x818f34b]
        mono(mono_reflection_get_custom_attrs_by_type+0x12e) [0x818f4ae]
        mono [0x80aa4ca]
        [0xb79b749f]
        [0xb79b73e7]
        [0xb79b6d5e]
        [0xb79b6c47]
        [0xb79b6ba8]
        [0xb79ac33b]
        [0xb79ac1be]
        mono(mono_runtime_exec_main+0xbb) [0x809fd6b]
        mono(mono_runtime_run_main+0x173) [0x80a0063]
        mono(mono_main+0x6b9) [0x805af09]
        mono [0x805a342]
        /lib/libc.so.6(__libc_start_main+0xe0) [0xb7d75fe0]
        mono [0x805a2b1]

Debug info from gdb:

Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d5faf0 (LWP 5410)]
[New Thread 0xb7425b90 (LWP 5412)]
[New Thread 0xb7fb4b90 (LWP 5411)]
0xffffe410 in __kernel_vsyscall ()
  3 Thread 0xb7fb4b90 (LWP 5411)  0xffffe410 in __kernel_vsyscall ()
  2 Thread 0xb7425b90 (LWP 5412)  0xffffe410 in __kernel_vsyscall ()
  1 Thread 0xb7d5faf0 (LWP 5410)  0xffffe410 in __kernel_vsyscall ()

Thread 3 (Thread 0xb7fb4b90 (LWP 5411)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7ec4846 in nanosleep () from /lib/libpthread.so.0
#2  0x08110a21 in collection_thread (unused=0x0) at collection.c:34
#3  0xb7ebd192 in start_thread (arg=0xb7fb4b90) at pthread_create.c:296
#4  0xb7e2302e in clone () from /lib/libc.so.6

Thread 2 (Thread 0xb7425b90 (LWP 5412)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7ec1566 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0x081136ef in timedwait_signal_poll_cond (cond=0xb791f1dc,
    mutex=0xb791f1c4, timeout=0x0, alertable=0) at handles.c:1443
#3  0x0811615d in _wapi_handle_timedwait_signal_handle (handle=0x404,
    timeout=0x0, alertable=0) at handles.c:1523
#4  0x081161cc in _wapi_handle_wait_signal_handle (handle=0x404, alertable=0)
    at handles.c:1483
#5  0x08129d6a in WaitForSingleObjectEx (handle=0x404, timeout=4294967295,
    alertable=0) at wait.c:200
#6  0x080b580a in finalizer_thread (unused=0x0) at gc.c:894
#7  0x080d6aaf in start_wrapper (data=0x8264eb8) at threads.c:589
#8  0x08125f82 in thread_start_routine (args=0xb77d4c18) at threads.c:282
#9  0x0813f975 in GC_start_routine (arg=0x26f40) at pthread_support.c:1369
#10 0xb7ebd192 in start_thread (arg=0xb7425b90) at pthread_create.c:296
#11 0xb7e2302e in clone () from /lib/libc.so.6

Thread 1 (Thread 0xb7d5faf0 (LWP 5410)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7dee9a9 in __libc_fork ()
    at ../nptl/sysdeps/unix/sysv/linux/i386/../fork.c:127
#2  0xb7ec67b4 in __fork () at ../nptl/sysdeps/unix/sysv/linux/pt-fork.c:26
#3  0xb7f5f0e9 in ?? () from /usr/lib/libglib-2.0.so.0
#4  0xb7e8eff4 in ?? () from /lib/libc.so.6
#5  0x0831a0d8 in ?? ()
#6  0x0831a078 in ?? ()
#7  0xb7fd0628 in ?? ()
#8  0xb7e8eff4 in ?? () from /lib/libc.so.6
#9  0x0831a0e0 in ?? ()
#10 0x08319ce0 in ?? ()
#11 0xb7c2f1b8 in ?? ()
#12 0xb7dc96f9 in _int_realloc (av=0x0, oldmem=0x1, bytes=1) at malloc.c:5016
#13 0xb7f5fd0d in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
#14 0xb7f601dc in g_spawn_command_line_sync () from /usr/lib/libglib-2.0.so.0
#15 0x0817ee11 in mono_handle_native_sigsegv (signal=11, ctx=0xb7c2fd0c)
    at mini-exceptions.c:1046
#16 0x08081001 in mono_arch_handle_altstack_exception (sigctx=0xb7c2fd0c,
    fault_addr=0x8, stack_ovf=0) at exceptions-x86.c:855
#17 <signal handler called>
#18 create_custom_attr (image=0x4f800, method=0x0, data=0x82a3a34 "\001",
    len=4) at reflection.c:7086
#19 0x0818f34b in mono_custom_attrs_construct (cinfo=0x83073f0)
    at reflection.c:7288
#20 0x0818f4ae in mono_reflection_get_custom_attrs_by_type (obj=0x25c30,
    attr_klass=0x0) at reflection.c:7698
#21 0x080aa4ca in custom_attrs_get_by_type (obj=0x25c30, attr_type=0x0)
    at icall.c:6911
#22 0xb79b749f in ?? ()
#23 0x00025c30 in ?? ()
#24 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
rolf at linux:~/test>
rolf at linux:~/test>
rolf at linux:~/test> gmcs test.cs && mono test.exe
test.cs(23,24): warning CS0219: The variable `cv' is assigned but its value is
never used
Compilation succeeded - 1 warning(s)
Stacktrace:

  at (wrapper managed-to-native)
System.MonoCustomAttrs.GetCustomAttributesInternal
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x00004>
  at (wrapper managed-to-native)
System.MonoCustomAttrs.GetCustomAttributesInternal
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0xffffffff>
  at System.MonoCustomAttrs.GetCustomAttributesBase
(System.Reflection.ICustomAttributeProvider,System.Type) <0x0001e>
  at System.MonoCustomAttrs.GetCustomAttributes
(System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x0001d>
  at System.MonoCustomAttrs.GetCustomAttributes
(System.Reflection.ICustomAttributeProvider,bool) <0x00086>
  at System.Reflection.Assembly.GetCustomAttributes (bool) <0x0000f>
  at test.Main () <0x000fa>
  at (wrapper runtime-invoke) System.Object.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        mono [0x817ed7f]
        mono [0x8081001]
        [0xffffe440]
        mono(mono_custom_attrs_construct+0x5b) [0x818f34b]
        mono(mono_reflection_get_custom_attrs_by_type+0x12e) [0x818f4ae]
        mono [0x80aa4ca]
        [0xb798e49f]
        [0xb798e3e7]
        [0xb798dd5e]
        [0xb798dc47]
        [0xb798dba8]
        [0xb798333b]
        [0xb79831be]
        mono(mono_runtime_exec_main+0xbb) [0x809fd6b]
        mono(mono_runtime_run_main+0x173) [0x80a0063]
        mono(mono_main+0x6b9) [0x805af09]
        mono [0x805a342]
        /lib/libc.so.6(__libc_start_main+0xe0) [0xb7d4cfe0]
        mono [0x805a2b1]

Debug info from gdb:

Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d36af0 (LWP 7538)]
[New Thread 0xb73fcb90 (LWP 7540)]
[New Thread 0xb7f8bb90 (LWP 7539)]
0xffffe410 in __kernel_vsyscall ()
  3 Thread 0xb7f8bb90 (LWP 7539)  0xffffe410 in __kernel_vsyscall ()
  2 Thread 0xb73fcb90 (LWP 7540)  0xffffe410 in __kernel_vsyscall ()
  1 Thread 0xb7d36af0 (LWP 7538)  0xffffe410 in __kernel_vsyscall ()

Thread 3 (Thread 0xb7f8bb90 (LWP 7539)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e9b846 in nanosleep () from /lib/libpthread.so.0
#2  0x08110a21 in collection_thread (unused=0x0) at collection.c:34
#3  0xb7e94192 in start_thread (arg=0xb7f8bb90) at pthread_create.c:296
#4  0xb7dfa02e in clone () from /lib/libc.so.6

Thread 2 (Thread 0xb73fcb90 (LWP 7540)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e98566 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0x081136ef in timedwait_signal_poll_cond (cond=0xb78f61dc,
    mutex=0xb78f61c4, timeout=0x0, alertable=0) at handles.c:1443
#3  0x0811615d in _wapi_handle_timedwait_signal_handle (handle=0x404,
    timeout=0x0, alertable=0) at handles.c:1523
#4  0x081161cc in _wapi_handle_wait_signal_handle (handle=0x404, alertable=0)
    at handles.c:1483
#5  0x08129d6a in WaitForSingleObjectEx (handle=0x404, timeout=4294967295,
    alertable=0) at wait.c:200
#6  0x080b580a in finalizer_thread (unused=0x0) at gc.c:894
#7  0x080d6aaf in start_wrapper (data=0x8264eb8) at threads.c:589
#8  0x08125f82 in thread_start_routine (args=0xb77ab4c8) at threads.c:282
#9  0x0813f975 in GC_start_routine (arg=0x26f40) at pthread_support.c:1369
#10 0xb7e94192 in start_thread (arg=0xb73fcb90) at pthread_create.c:296
#11 0xb7dfa02e in clone () from /lib/libc.so.6

Thread 1 (Thread 0xb7d36af0 (LWP 7538)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7df3591 in select () from /lib/libc.so.6
#2  0xb7f36de9 in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
#3  0xb7f371dc in g_spawn_command_line_sync () from /usr/lib/libglib-2.0.so.0
#4  0x0817ee11 in mono_handle_native_sigsegv (signal=11, ctx=0xb7c06d0c)
    at mini-exceptions.c:1046
#5  0x08081001 in mono_arch_handle_altstack_exception (sigctx=0xb7c06d0c,
    fault_addr=0x8, stack_ovf=0) at exceptions-x86.c:855
#6  <signal handler called>
#7  create_custom_attr (image=0x4f800, method=0x0, data=0x82a3a34 "\001",
    len=4) at reflection.c:7086
#8  0x0818f34b in mono_custom_attrs_construct (cinfo=0x83073f0)
    at reflection.c:7288
#9  0x0818f4ae in mono_reflection_get_custom_attrs_by_type (obj=0x25c30,
    attr_klass=0x0) at reflection.c:7698
#10 0x080aa4ca in custom_attrs_get_by_type (obj=0x25c30, attr_type=0x0)
    at icall.c:6911
#11 0xb798e49f in ?? ()
#12 0x00025c30 in ?? ()
#13 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
rolf at linux:~/test>


-- 
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