[Mono-bugs] [Bug 465825] New: CCW crashes when marshalling arrays
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jan 13 14:56:02 EST 2009
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: mono-bugs at lists.ximian.com
ReportedBy: eb1 at sil.org
QAContact: mono-bugs at lists.ximian.com
CC: eb1 at sil.org
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.
More information about the mono-bugs
mailing list