[Mono-dev] Trouble with delegate ctors on generic sharing

Mark Probst mark.probst at gmail.com
Fri Sep 19 14:00:42 EDT 2008


Hey,

The attached program triggers the following bug when generic sharing is
enabled (MONO_GENERIC_SHARING=all):

The call to the delegate constructor in makeDel() needs to look up the
constructor in the RGCTX, because the delegate type is a generic for
which code cannot be shared in the general case (because its type
argument is a value type).  Then the constructor method is invoked via
an indirect call.

The constructor is a runtime method, so mono_jit_compile_method_inner()
doesn't actually compile it but returns a trampoline for an icall
wrapper.  When that trampoline is processed by mono_magic_trampoline()
the code calling the trampoline is supposed to be patched, which is
impossible in this case and we hit a failed assertion in
mono_arch_patch_callsite().

What do we do about this?  I don't see how I can figure out the
circumstances in mono_magic_trampoline().  IMHO mono_compile_method()
should always return method code, never trampoline code.  Another
possibility would be to detect the issue in instantiate_other_info()
(metadata/generic-sharing.c), but I don't know how I could handle it
there, since the trampoline is opaque for metadata.

Mark

-------------- next part --------------
A non-text attachment was scrubbed...
Name: generic-delegate-ctor.2.cs
Type: text/x-csharp
Size: 390 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080919/fdc79d6f/attachment.bin 


More information about the Mono-devel-list mailing list