[Mono-bugs] [Bug 80263][Maj] New - Getting custom attributes when one attribute was initialized with a params array that includes a string array crashes the runtime

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Dec 14 16:03:51 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dmitchell at logos.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80263

--- shadow/80263	2006-12-14 16:03:51.000000000 -0500
+++ shadow/80263.tmp.28232	2006-12-14 16:03:51.000000000 -0500
@@ -0,0 +1,98 @@
+Bug#: 80263
+Product: Mono: Runtime
+Version: 1.2
+OS: Mac OS X 10.3
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: dmitchell at logos.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Getting custom attributes when one attribute was initialized with a params array that includes a string array crashes the runtime
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+Under certain circumstances, calling MethodInfo.GetCustomAttributes() can 
+crash the runtime
+
+The best way to characterize this problem is with code, which I'll 
+reference in the steps to reproduce and the additional information 
+sections:
+
+-- Begin Program.cs --
+using Sytem;
+using System.Reflection;
+
+namespace MonoBug
+{
+        public class Program
+        {
+                static private void Main(string[] args)
+                {
+                        Assembly assembly = Assembly.GetExecutingAssembly
+();
+                        Type type = assembly.GetType("MonoBug.Program", 
+true);
+                        MethodInfo info = type.GetMethod("Foo");
+                        object[] attributes = info.GetCustomAttributes
+(false);
+                        foreach (object obj in attributes)
+                        {
+                                Console.WriteLine("Attribute of type {0} 
+found", obj.GetType().ToString());
+                        }
+                }
+
+                [My("blah", new string[] { "crash" }, "additional 
+parameter")]
+                public void Foo()
+                {
+                }
+        }
+
+        [AttributeUsage(AttributeTargets.Method)]
+        class MyAttribute : Attribute
+        {
+                public MyAttribute(params object[] arguments)
+                {
+                }
+        }
+}
+-- End Program.cs
+
+Steps to reproduce the problem:
+1. Enter the code above into a cs file
+2. Compile it
+3. Run it
+
+Actual Results:
+The runtime will crash; it complains about some sort of unknown type, and 
+the crash seems to occur in the native code that handles the call to 
+GetCustomAttributes. As far as I can tell, the constructor for 
+MyAttribute is never entered.
+
+Expected Results:
+The call to GetCustomAttributes should not crash the runtime, and it 
+should return the correct attributes.
+
+How often does this happen? 
+Every time in MacOS, never in Windows XP SP2
+
+Additional Information:
+
+/Any/ of the following changes to Program.cs will cause the application 
+to run without any problems:
+
+1. Remove the prameters "blah" and "additional prameter" from the call to 
+the constructor of MyAttribute
+2. Remove the AttributeUsage attribute from the MyAttribute class
+3. Remove all items from the string array (the string "crash")
+4. Make the string array an object array
+5. Replace the string array with an array of some other type, such as int


More information about the mono-bugs mailing list