[Mono-bugs] [Bug 690077] New: Marshaling out/ref/return parameter as LPStruct does not work

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 26 17:50:48 EDT 2011


https://bugzilla.novell.com/show_bug.cgi?id=690077

https://bugzilla.novell.com/show_bug.cgi?id=690077#c0


           Summary: Marshaling out/ref/return parameter as LPStruct does
                    not work
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: Ivo at UFO-Net.nl
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User
           Blocker: No


Description of Problem:
In a COM interop interface, Mono can not marshal an out/ref/return parameter of
type System.Guid as a LPStruct. It does work for 'in' parameters.

Steps to reproduce the problem:
1. Create a COM wrapper interface containing at least one method which returns
a Guid structure, which is marshaled as LPStruct (see Test case).
2. Create any COM object (set the GuidAttribute of the created interface to one
implemented by this COM object; the fields of the interface do not have to
match).
3. Try to cast the newly created object to the interface type.


Actual Results:
Mono fails with an assertion when the COM proxy object is converted to an
interface type containing any methods with an out/ref parameter or return value
which is marshaled as LPStruct. Note that it fails even if the offending method
is not used.

* Assertion at marshal.c:5821, condition `!t->byref' not met

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native)
object.__icall_wrapper_mono_upgrade_remote_class_wrapper (object,object)
<0xffffffff>
  at (wrapper proxy_isinst) object.__proxy_isinst_wrapper_IVirtualBoxCrippled
(object) <0xffffffff>
  at ConsoleApplication1.Program.Main (string[]) <0x000d3>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>


Expected Results:
No assert.

How often does this happen? 
Always.

Additional Information:
Trying to interface with VirtualBox using XPCOM.

Test case:
Note that the actual type of the COM/XPCOM object is irrelevant. Mono fails
because of how the return value of IVirtualBoxCrippled.get_Version() is
Marshaled. Note also that the interface is not as it should be, this is a
simplified example, and if the method is not called, it should not matter;
also, I have discovered the issue on a correct interface. Note also that the
code to construct the XPCOM object on Unix is left out, because it is very
specific to the use case (VirtualBox). If necessary, I can post it.

    [Guid("d2de270c-1d4b-4c9e-843f-bbb9b47269ff")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    [ComImport()]
    interface IVirtualBoxCrippled {
        [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType =
MethodCodeType.Runtime)]
        [return: MarshalAs(UnmanagedType.LPStruct)]
        Guid get_Version();
    }
    static unsafe void Main(string[] args) {
        Object vb;
        if (Environment.OSVersion.Platform != PlatformID.Unix) {
            //Set vb using XPCOM initialization code
        } else {
            vb =
Activator.CreateInstance(Type.GetTypeFromProgID("VirtualBox.VirtualBox"));
        }
        IVirtualBoxCrippled vb2 = (IVirtualBoxCrippled)vb;
    }

-- 
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