Bugzilla – Bug 319335
[GMCS] assertion failed: (ex_info->handlers)
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by malekith@pld-linux.org 2005-10-19 17:37:26 MST ---- Description of Problem: When we try to use TypeBuilder.GetMethod, when an exception block is being generated, the assertion fires. #v+ using System; using System.Reflection; using System.Reflection.Emit; class M { static void Main () { /// INITIAL ASSEMBLY CREATION AssemblyName name = new AssemblyName(); name.Name = "o"; AssemblyBuilder builder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave); ModuleBuilder mb = builder.DefineDynamicModule("out", "bla.dll"); /////////// TypeBuilder func = mb.DefineType("Foo", TypeAttributes.Public); GenericTypeParameterBuilder[] func_gp = func.DefineGenericParameters("A"); func.SetParent(typeof(object)); MethodBuilder func_apply = func.DefineMethod("bar", MethodAttributes.Public, typeof(object), new Type[] { }); ILGenerator il = func_apply.GetILGenerator(); il.BeginExceptionBlock (); // exception here! MethodInfo mi = TypeBuilder.GetMethod (func.GetGenericTypeDefinition ().MakeGenericType (new Type [] { func_gp[0] }), func_apply); il.BeginFinallyBlock (); il.EndExceptionBlock (); il.Emit (OpCodes.Ldnull); il.Emit (OpCodes.Ret); func.CreateType(); builder.Save("bla.dll"); } } #v- when run, it gives: ** ERROR **: file reflection.c: line 838 (method_encode_clauses): assertion failed: (ex_info->handlers) aborting... The workaround is to additionally run this GetMethod before the BeginExceptionBlock, so the type is initialized. Works fine on ms.net aug ctp. ---- Additional Comments From martin@ximian.com 2006-06-21 10:17:08 MST ---- Fixed in SVN. Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>amd64 pld linux</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".