|
Bugzilla – Full Text Bug Listing |
| Summary: | CCW crashes when marshalling arrays | ||
|---|---|---|---|
| Product: | [Mono] Mono: Runtime | Reporter: | Eberhard Beilharz <eb1> |
| Component: | interop | Assignee: | Jonathan Chambers <joncham> |
| Status: | RESOLVED FIXED | QA Contact: | Mono Bugs <mono-bugs> |
| Severity: | Normal | ||
| Priority: | P5 - None | CC: | eb1, forgotten_vxPDddArjq, joncham |
| Version: | SVN | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Ubuntu | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
| Attachments: |
A patch for the cominterop tests that shows the problem
Proposed fix |
||
Created attachment 264850 [details]
Proposed fix
Jonathan, could you look at the patch ? This seems to be fixed with #136029 |
Created attachment 264847 [details] 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.