[Mono-bugs] [Bug 675586] New: 2.10 regression: failure instantiate generic+nested Type paramter when constructing attribute

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Feb 28 11:47:04 EST 2011


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

https://bugzilla.novell.com/show_bug.cgi?id=675586#c0


           Summary: 2.10 regression: failure instantiate generic+nested
                    Type paramter when constructing attribute
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.10.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: generics
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: brian at sooloos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US)
AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20

If a parameter of type 'System.Type' is passed to an attribute constructor and
the type is nested within the generic type, mono prints "Cannot load type"
trace, then passes null into the attribute constructor, even though the type is
valid.

This situation produces no failure on ms.net 2.0/4.0 runtimes, and also works
properly with mono 2.8.x runtime.

I've constructed a small program that reproduces this bug.




Reproducible: Always

Steps to Reproduce:
brian at brianmbp ~ $ mono --version                                              
                                                                               
                        [ 1 ]
Mono JIT compiler version 2.10.1 (tarball Fri Feb 25 15:56:49 MST 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       normal
    Notification:  Thread + polling
    Architecture:  x86
    Disabled:      none
    Misc:          debugger softdebug 
    LLVM:          yes(2.9svn-mono)
    GC:            Included Boehm (with typed GC)
brian at brianmbp ~ $ mcs --version
Mono C# compiler version 2.10.1.0
brian at brianmbp ~ $ cat t.cs
using System;
using System.Reflection;

public class ExtensionAttribute : Attribute {
    public readonly Type ExtendsType;
    public ExtensionAttribute(Type extendstype) { 
        if (extendstype == null)
            throw new ArgumentNullException("extendstype");
        ExtendsType = extendstype; 
    }
}

public class Bar<T> {
    public class Baz { }
}

[Extension(typeof(Bar<string>.Baz))]
public class Extends_Bar_string_Baz { }

public static class Foo {
    public static void Main(string[] args) {
        foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) {
            type.GetCustomAttributes(typeof(ExtensionAttribute), false);
        }
    }
}
brian at brianmbp ~ $ mcs t.cs
brian at brianmbp ~ $ mono t.exe
Cannot load type 'Bar`1+.Baz[[System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]'

Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: extendstype
  at ExtensionAttribute..ctor (System.Type extendstype) [0x00000] in <filename
unknown>:0 
  at (wrapper managed-to-native)
System.MonoCustomAttrs:GetCustomAttributesInternal
(System.Reflection.ICustomAttributeProvider,System.Type,bool)
  at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider
obj, System.Type attributeType) [0x00000] in <filename unknown>:0 
  at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj,
System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
  at System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean
inherit) [0x00000] in <filename unknown>:0 
  at Foo.Main (System.String[] args) [0x00000] in <filename unknown>:0 
brian at brianmbp ~ $ echo $?                                                      
1

Actual Results:  
test program prints "Cannot load type" trace then throws ArgumentNullException
during attribute construction.

Expected Results:  
test program exits with status=0 without printing anything.

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