Bugzilla – Bug 315121
C# compiler throws InternalErrorException in ConstructorInitializer:GetOverloadedConstructor
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by patrick@kinitos.com 2004-06-15 12:34:50 MST ---- When compiling the following classes the compiler throws uncaught exception Mono.CSharp.InternalErrorException. Code for classes; // begin public class MyClass { public MyClass( params System.String [] parameters ) { } } public class ChildClass : MyClass {} // end Output from c# compiler; Unhandled Exception: Mono.CSharp.InternalErrorException: Internal error in <0x00541> Mono.CSharp.ConstructorInitializer:GetOverloadedConstructor (Mono.CSharp.TypeContainer) in <0x00021> Mono.CSharp.ConstructorInitializer:CheckObsoleteAttribute (Mono.CSharp.TypeContainer,Mono.CSharp.Location) in <0x0007b> Mono.CSharp.ConstructorBaseInitializer:CheckObsoleteAttribute (Mono.CSharp.TypeContainer,Mono.CSharp.Location) in <0x00369> Mono.CSharp.Constructor:Emit (Mono.CSharp.TypeContainer) in <0x00429> Mono.CSharp.TypeContainer:Emit () in <0x008de> Mono.CSharp.RootContext:EmitCode () in <0x00c76> Mono.CSharp.Driver:MainDriver (string[]) in <0x00012> Mono.CSharp.Driver:Main (string[]) command line options used; mcs -target:library -out:myclass.dll MyClass.cs specific version of mono; test@linuxvpc:~/depot/Product/Dev/Platform/temp$ mono -V Mono JIT compiler version 0.95.20040611, (C) 2002-2004 Novell, Inc and Contributors. www.go-mono.com TLS: normal GC: Included Boehm (with typed GC) SIGSEGV : normal Globalization: none Note this works ok for us in beta 1. This seems to be very similar to https://bugzilla.novell.com/show_bug.cgi?id=MONO59267, except that the testcase in it succeeds for me and this case seems alot more general. I have tried playing with the test above and i can't come up with a simpler case. Removing inheritence or providing a constructor with no params, will both make it work. ---- Additional Comments From miguel@ximian.com 2004-06-15 15:43:24 MST ---- Fixed on CVS. Marek, can you check if my fix is correct? ---- Additional Comments From patrick@kinitos.com 2004-06-17 18:12:36 MST ---- I continue to have problems with this. I got and built the latest copy of mcs (and mono) from anon-cvs today and it stils exhibits this problem. So I took a look at the code to see what was happening. If you look at mcs/class.cs, Mono.CSharp.ConstructorInitializer:GetOverloadedConstructor function, you can see the first thing in the foreach loop is a check if the caller has any arguments. If they are not we will only return a constructors that has a zero length arguement list. However the other option should be to take a constructor with one parameter that has the "params" modifier. I have made and tested the following change to the if(Arguments == null) block, (currently on line 3246); if (Arguments == null) { if (c.ParameterTypes.Length == 0 || (c.ParameterInfo.Count == 1 && c.ParameterInfo.ParameterModifier (0) == Parameter.Modifier.PARAMS)) return c; continue; } I have tested this with the following code and it now works; public class MyClass { public MyClass( params System.String [] parameters ) { System.Console.WriteLine(parameters.Length + "\n"); } } public class ChildClass : MyClass {} public class test { static void Main () { ChildClass c = new ChildClass(); } } Let me know if this is useful, or if i have the wrong version of the code from CVS. Thanks Patrick ---- Additional Comments From patrick@kinitos.com 2004-06-21 12:14:11 MST ---- This works for me now, Thank you very much for getting a fix in so quickly this will get me going again. Should I set the bug to verified now? Thanks Patrick Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Debian Sarge</cf_op_sys_details>