[Mono-bugs] [Bug 525338] New: klass->parent->vtable_size is incorrect for generic classes.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Jul 26 19:22:22 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=525338
Summary: klass->parent->vtable_size is incorrect for generic
classes.
Classification: Mono
Product: Mono: Runtime
Version: SVN
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: JIT
AssignedTo: lupus at novell.com
ReportedBy: miguel at novell.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
The following test crashes the Mono runtime (isolated from a larger test for
Silverlight):
using System;
using System.Reflection;
[DefaultMemberAttribute("flag")]
public class MyBase {
public bool flag;
}
public class Generic2<T> where T : MyBase {
}
public class Crash {
static void Main ()
{
Type gType = typeof(Generic2<MyBase>).GetGenericTypeDefinition();
Type typeArg = gType.GetGenericArguments()[0];
FieldInfo fi = typeArg.GetDefaultMembers()[0] as FieldInfo;
}
}
The error generated is:
**
** ERROR:(icall.c:3789):ves_icall_Type_GetMethodsByName: assertion failed:
(method->slot < nslots)
Stacktrace:
at (wrapper managed-to-native) System.MonoType.GetMethodsByName
(string,System.Reflection.BindingFlags,bool,System.Type) <0x0005d>
at (wrapper managed-to-native) System.MonoType.GetMethodsByName
(string,System.Reflection.BindingFlags,bool,System.Type) <0xffffffff>
at System.MonoType.GetMethods (System.Reflection.BindingFlags) <0x00023>
at System.Type.FindMembers
(System.Reflection.MemberTypes,System.Reflection.BindingFlags,System.Reflection.MemberFilter,object)
<0x00301>
at System.Type.GetMember
(string,System.Reflection.MemberTypes,System.Reflection.BindingFlags) <0x00074>
at System.Type.GetMember (string,System.Reflection.BindingFlags) <0x0002b>
at System.Type.GetMember (string) <0x00020>
at System.Type.GetDefaultMembers () <0x0008f>
at Crash.Main () <0x00058>
at (wrapper runtime-invoke) object.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>
The problem is that the number of slots computed in the routine is done like
this:
if (is_generic_parameter (type->type)){
nslots = klass->parent->vtable_size;
} else
nslots = MONO_CLASS_IS_INTERFACE (klass) ? mono_class_num_methods
(klass) : klass->vtable_size;
In this case the path taken is nslots = klass->parent->vtable_size which
reports 0. But since the code iterates to the parent classes (due to the flag
DeclaredOnly not being set) eventually it fetches the System.Object.Equals
method and this is where the code hits the assertion.
Either the klass->parent_vtable_size is incorrectly computed in this case or
the code should perform the same looping through parent classes to determine
the number of methods slots required as it is done just a few lines later.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list