[Mono-dev] SEGV in mono_class_is_assignable_from in gmcs

Casey Marshall casey.s.marshall at gmail.com
Fri Sep 5 17:22:21 EDT 2008


I'm getting a SEGV in the function `mono_class_is_assignable_from' when 
trying to compile some internal code. I can't get the location in my 
source code where the error occurs, but I'll add some info from GDB to 
this email. Has anyone seen something like this before?

This is with a mono/gmcs from the mono-2-0 branch, revision 110293. I 
*think* the class being compiled is of the form "class Foo<T> : 
IComparable<Foo<T>>", but I've been unsuccessful in getting a simple 
test case so far.

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x2b9ff82c96e0 (LWP 17401)]
> 0x00000000004a6314 in mono_class_is_assignable_from (klass=0x8d0330, oklass=0x1102200) at class.c:5775
> 5775                    if (MONO_CLASS_IMPLEMENTS_INTERFACE (oklass, klass->interface_id))
> (gdb) print *klass
> $1 = {element_class = 0x8d0330, cast_class = 0x8d0330, supertypes = 0x90e470, idepth = 1, rank = 0 '\0', instance_size = 16, inited = 1, init_pending = 0, size_inited = 1, valuetype = 0,
>   enumtype = 0, blittable = 1, unicode = 0, wastypebuilder = 0, min_align = 1, packing_size = 0, ghcimpl = 0, has_finalize = 0, marshalbyref = 0, contextbound = 0, delegate = 0,
>   gc_descr_inited = 0, has_cctor = 0, has_references = 0, has_static_refs = 0, no_special_static_fields = 0, is_com_object = 0, exception_type = 0 '\0', parent = 0x0, nested_in = 0x0,
>   nested_classes = 0x0, image = 0x8b1d50, name = 0x2aaaaace0fdc "IComparable", name_space = 0x2aaaaace09a0 "System", enum_basetype = 0x0, declsec_flags = 0, type_token = 33554441,
>   vtable_size = 0, interface_count = 0, interface_id = 0, max_interface_id = 0, interface_offsets_count = 1, interfaces_packed = 0x90e4a0, interface_offsets_packed = 0x90e4a8,
>   interface_bitmap = 0x90e4b0 "\001", interfaces = 0x0, sizes = {class_size = 0, element_size = 0, generic_param_token = 0}, flags = 161, field = {first = 3, count = 0}, method = {
>     first = 128, count = 1}, property = {first = 0, count = 0}, event = {first = 0, count = 0}, marshal_info = 0x0, fields = 0x0, properties = 0x0, events = 0x0, methods = 0x9037c8,
>   this_arg = {data = {klass = 0x8d0330, type = 0x8d0330, array = 0x8d0330, method = 0x8d0330, generic_param = 0x8d0330, generic_class = 0x8d0330}, attrs = 0, type = MONO_TYPE_CLASS,
>     num_mods = 0, byref = 1, pinned = 0, modifiers = 0x8d0424}, byval_arg = {data = {klass = 0x8d0330, type = 0x8d0330, array = 0x8d0330, method = 0x8d0330, generic_param = 0x8d0330,
>       generic_class = 0x8d0330}, attrs = 0, type = MONO_TYPE_CLASS, num_mods = 0, byref = 0, pinned = 0, modifiers = 0x8d0434}, generic_class = 0x0, generic_container = 0x0,
>   reflection_info = 0x0, gc_descr = 0x0, runtime_info = 0x0, next_class_cache = 0x0, vtable = 0x0}
> (gdb) print *oklass
> $2 = {element_class = 0x1102200, cast_class = 0x1102200, supertypes = 0xf5abf8, idepth = 2, rank = 0 '\0', instance_size = 0, inited = 1, init_pending = 0, size_inited = 0, valuetype = 0,
>   enumtype = 0, blittable = 0, unicode = 0, wastypebuilder = 0, min_align = 0, packing_size = 0, ghcimpl = 0, has_finalize = 0, marshalbyref = 0, contextbound = 0, delegate = 0,
>   gc_descr_inited = 0, has_cctor = 0, has_references = 0, has_static_refs = 0, no_special_static_fields = 0, is_com_object = 0, exception_type = 0 '\0', parent = 0x8b1b40, nested_in = 0x0,
>   nested_classes = 0x0, image = 0x2aaaac2bd000, name = 0xf54ad0 "XXX`1", name_space = 0xf54ae0 "XXX.XXX.XXX.XXX", enum_basetype = 0x0, declsec_flags = 0,
>   type_token = 33554437, vtable_size = 0, interface_count = 0, interface_id = 0, max_interface_id = 0, interface_offsets_count = 0, interfaces_packed = 0x0, interface_offsets_packed = 0x0,
>   interface_bitmap = 0x0, interfaces = 0x0, sizes = {class_size = 0, element_size = 0, generic_param_token = 0}, flags = 1048577, field = {first = 0, count = 0}, method = {first = 0,
>     count = 0}, property = {first = 0, count = 0}, event = {first = 0, count = 0}, marshal_info = 0x0, fields = 0x0, properties = 0x0, events = 0x0, methods = 0x0, this_arg = {data = {
>       klass = 0xfe5f60, type = 0xfe5f60, array = 0xfe5f60, method = 0xfe5f60, generic_param = 0xfe5f60, generic_class = 0xfe5f60}, attrs = 0, type = MONO_TYPE_GENERICINST, num_mods = 0,
>     byref = 1, pinned = 0, modifiers = 0x11022f4}, byval_arg = {data = {klass = 0xfe5f60, type = 0xfe5f60, array = 0xfe5f60, method = 0xfe5f60, generic_param = 0xfe5f60,
>       generic_class = 0xfe5f60}, attrs = 0, type = MONO_TYPE_GENERICINST, num_mods = 0, byref = 0, pinned = 0, modifiers = 0x1102304}, generic_class = 0xfe5f60, generic_container = 0x0,
>   reflection_info = 0x0, gc_descr = 0x0, runtime_info = 0x0, next_class_cache = 0x0, vtable = 0x0}

The null pointer seems to be oklass->interface_bitmap, which is accessed 
by the MONO_CLASS_IMPLEMENTS_INTERFACE macro:

> (gdb) print oklass->interface_bitmap
> $3 = (guint8 *) 0x0

Managed stacktrace:

> Stacktrace:
> 
>   at (wrapper managed-to-native) System.Type.type_is_assignable_from (System.Type,System.Type) <0x00048>
>   at (wrapper managed-to-native) System.Type.type_is_assignable_from (System.Type,System.Type) <0xffffffff>
>   at System.Type.IsAssignableFrom (System.Type) [0x0007c] in .../mcs/class/corlib/System/Type.cs:695
>   at Mono.CSharp.Convert.ImplicitStandardConversionExists (Mono.CSharp.Expression,System.Type) [0x00499] in .../mcs/mcs/convert.cs:877
>   at Mono.CSharp.Convert.ImplicitReferenceConversionCore (Mono.CSharp.Expression,System.Type) [0x0014c] in .../mcs/mcs/convert.cs:369
>   at Mono.CSharp.Convert.ImplicitReferenceConversionExists (Mono.CSharp.Expression,System.Type) [0x00044] in .../mcs/mcs/convert.cs:478
>   at Mono.CSharp.Convert.ImplicitStandardConversionExists (Mono.CSharp.Expression,System.Type) [0x0035d] in .../mcs/mcs/convert.cs:824
>   at Mono.CSharp.Convert.ImplicitConversionExists (Mono.CSharp.EmitContext,Mono.CSharp.Expression,System.Type) [0x0002a] in .../mcs/mcs/convert.cs:654
>   at Mono.CSharp.MethodGroupExpr.IsArgumentCompatible (Mono.CSharp.EmitContext,Mono.CSharp.Parameter/Modifier,Mono.CSharp.Argument,Mono.CSharp.Parameter/Modifier,System.Type) [0x0004a] in .../mcs/mcs/ecore.cs:3921
>   at Mono.CSharp.MethodGroupExpr.IsApplicable (Mono.CSharp.EmitContext,System.Collections.ArrayList,int,System.Reflection.MethodBase&,bool&) [0x001a8] in .../mcs/mcs/ecore.cs:3883
>   at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.EmitContext,System.Collections.ArrayList&,bool,Mono.CSharp.Location) [0x0014a] in .../mcs/mcs/ecore.cs:4155
>   at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/expression.cs:4870
>   at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.EmitContext) [0x0013e] in .../mcs/mcs/expression.cs:4812
>   at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext,Mono.CSharp.ResolveFlags) [0x00067] in .../mcs/mcs/ecore.cs:469
>   at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/ecore.cs:496
>   at Mono.CSharp.Assign.DoResolve (Mono.CSharp.EmitContext) [0x00002] in .../mcs/mcs/assign.cs:299
>   at Mono.CSharp.SimpleAssign.DoResolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/assign.cs:415
>   at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext,Mono.CSharp.ResolveFlags) [0x00067] in .../mcs/mcs/ecore.cs:469
>   at Mono.CSharp.Expression.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/ecore.cs:496
>   at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/ecore.cs:1300
>   at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.EmitContext) [0x0000b] in .../mcs/mcs/statement.cs:746
>   at Mono.CSharp.If.Resolve (Mono.CSharp.EmitContext) [0x00115] in .../mcs/mcs/statement.cs:295  
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/statement.cs:2522
>   at Mono.CSharp.If.Resolve (Mono.CSharp.EmitContext) [0x00115] in .../mcs/mcs/statement.cs:295  
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/statement.cs:2522
>   at ArrayForeach.Resolve (Mono.CSharp.EmitContext) [0x0025e] in .../mcs/mcs/statement.cs:5235   
>   at Mono.CSharp.Foreach.Resolve (Mono.CSharp.EmitContext) [0x000fa] in .../mcs/mcs/statement.cs:5114
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/statement.cs:2522
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.Block.Resolve (Mono.CSharp.EmitContext) [0x000e6] in .../mcs/mcs/statement.cs:2231
>   at Mono.CSharp.ExplicitBlock.Resolve (Mono.CSharp.EmitContext) [0x00000] in .../mcs/mcs/statement.cs:2522
>   at Mono.CSharp.EmitContext.ResolveTopBlock (Mono.CSharp.EmitContext,Mono.CSharp.ToplevelBlock,Mono.CSharp.Parameters,Mono.CSharp.IMethodData,bool&) [0x0007e] in .../mcs/mcs/codegen.cs:782
>   at Mono.CSharp.EmitContext.EmitTopBlock (Mono.CSharp.IMethodData,Mono.CSharp.ToplevelBlock) [0x00007] in .../mcs/mcs/codegen.cs:730
>   at Mono.CSharp.MethodData.Emit (Mono.CSharp.DeclSpace) [0x0009e] in .../mcs/mcs/class.cs:5236  
>   at Mono.CSharp.Method.Emit () [0x0005e] in .../mcs/mcs/class.cs:4366
>   at Mono.CSharp.TypeContainer.EmitType () [0x0025a] in .../mcs/mcs/class.cs:2284
>   at Mono.CSharp.RootContext.EmitCode () [0x00026] in .../mcs/mcs/rootcontext.cs:327
>   at Mono.CSharp.Driver.Compile () [0x0033e] in .../mcs/mcs/driver.cs:1704
>   at Mono.CSharp.Driver.Main (string[]) [0x0002e] in .../mcs/mcs/driver.cs:308
>   at (wrapper runtime-invoke) Mono.CSharp.Driver.runtime_invoke_int_string[] (object,intptr,intptr,intptr) <0xffffffff>

Thanks.


More information about the Mono-devel-list mailing list