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


           Summary: CCW crashes when marshalling arrays
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
                CC: [email protected]
          Found By: ---


Created an attachment (id=264847)
 --> (https://bugzilla.novell.com/attachment.cgi?id=264847)
A patch for the cominterop tests that shows the problem

Calling a managed method from unmanaged code via COM fails if a C style array
is passed as an in parameter.

Example of the IDL:

HRESULT EatCookies(
    [in] int cCookies,
    [in, size_is(cCookies)] int* cookies);

C# implementation of EatCookies:

public void EatCookies(int cCookies, int[] cookies)
{
    Console.Write("Eating {0} cookies: ", cCookies);
    for (int i = 0; i < cCookies; i++)
        Console.Write("{0}, ", cookies[i]);
    Console.WriteLine();
}

Interop defined as:

[MethodImpl(MethodImplOptions.InternalCall,
MethodCodeType=MethodCodeType.Runtime)]
void EatCookies(int cCookies, [MarshalAs(UnmanagedType.LPArray,
SizeParamIndex=0)] int[] cookies);

Call EatCookies from C++:

    m_customer->EatCookies(1, cookies);

When running it crashes:

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at System.String.memcpy4 (System.Byte* dest, System.Byte* src, Int32 size)
[0x00000] 
  at System.String.memcpy (System.Byte* dest, System.Byte* src, Int32 size)
[0x00000] 
  at (wrapper native-to-managed) IBakery.ICustomer:EatCookies
(intptr,int,int[])


Attached are patches for the cominterop tests that demonstrate the problem, and
a fix to the CCW marshaling that fixes the crash.

-- 
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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to