[Mono-bugs] [Bug 668506] New: Type.IsAssignableFrom can segfault with contravariant delegates
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Jan 31 22:59:48 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=668506
https://bugzilla.novell.com/show_bug.cgi?id=668506#c0
Summary: Type.IsAssignableFrom can segfault with contravariant
delegates
Classification: Mono
Product: Mono: Runtime
Version: SVN
Platform: x86-64
OS/Version: Linux
Status: NEW
Severity: Major
Priority: P5 - None
Component: generics
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: knielsen at ariasolutions.com
QAContact: mono-bugs at lists.ximian.com
Found By: Community User
Blocker: ---
Description of Problem:
The mono runtime will segfault when calling Type.IsAssignableFrom with "this"
equal to a constructed contravariant generic delegate, and with "c" equal
to the generic type definition of the same delegate.
Steps to reproduce the problem:
1. run the following program:
using System;
using System.Reflection;
namespace MonoGenericsCrash
{
static class IsAssignableFromTest
{
delegate void MyAction<in T>(T ag);
public static void Main()
{
typeof(MyAction<string>).IsAssignableFrom(typeof(MyAction<>));
}
}
}
Actual Results: Program segfaults:
#6 mono_class_is_variant_compatible (klass="MyAction`1", oklass="MyAction`1")
at class.c:7206
#7 0x0000000000509633 in mono_class_is_assignable_from (klass="MyAction`1",
oklass="MyAction`1") at class.c:7293
#8 0x0000000041182410 in ?? ()
#9 0x00000000024c7780 in ?? ()
#10 0x00007f881a1b1d48 in ?? ()
#11 0x0000000000000000 in ?? ()
Expected Results: Program should not segfault
How often does this happen? always
Additional Information:
The problem appears to be in the mono_class_is_assignable_from method. Before
calling mono_class_is_variant_compatible with the two delegate types, it should
probably check to make sure both types have variant generic params, instead of
just the first type.
I will attach a patch that fixes this issue.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list