Bugzilla – Attachment 264847 Details for
Bug 465825
CCW crashes when marshalling arrays
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
[patch]
A patch for the cominterop tests that shows the problem
ccw_array_tests.patch (text/plain), 14.65 KB, created by
Eberhard Beilharz
on 2009-01-13 19:56:01 UTC
(
hide
)
Description:
A patch for the cominterop tests that shows the problem
Filename:
MIME Type:
Creator:
Eberhard Beilharz
Created:
2009-01-13 19:56:01 UTC
Size:
14.65 KB
patch
obsolete
>Index: mono/mono/tests/cominterop.cs >=================================================================== >--- mono.orig/mono/tests/cominterop.cs 2009-01-12 15:00:30.000000000 +0100 >+++ mono/mono/tests/cominterop.cs 2009-01-13 15:15:21.000000000 +0100 >@@ -11,94 +11,99 @@ > public class Tests > { > >- [DllImport("libtest")] >+#if WIN32 >+ private const string libName = "libtest"; >+#else >+ private const string libName = "test"; >+#endif >+ [DllImport(libName)] > public static extern int mono_test_marshal_bstr_in([MarshalAs(UnmanagedType.BStr)]string str); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_bstr_out([MarshalAs(UnmanagedType.BStr)] out string str); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_bstr_in_null([MarshalAs(UnmanagedType.BStr)]string str); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_bstr_out_null([MarshalAs(UnmanagedType.BStr)] out string str); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_sbyte([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_byte([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_short([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_ushort([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_int([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_uint([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_long([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_ulong([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_float([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_double([MarshalAs(UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_in_bstr ([MarshalAs (UnmanagedType.Struct)]object obj); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_bool_true ([MarshalAs (UnmanagedType.Struct)]object obj); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_bool_false ([MarshalAs (UnmanagedType.Struct)]object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_sbyte([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_byte([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_short([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_ushort([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_int([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_uint([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_long([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_ulong([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_float([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_double([MarshalAs(UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_bstr ([MarshalAs (UnmanagedType.Struct)]out object obj); > >- [DllImport("libtest")] >+ [DllImport(libName)] > public static extern int mono_test_marshal_variant_out_bool_true ([MarshalAs (UnmanagedType.Struct)]out object obj); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_bool_false ([MarshalAs (UnmanagedType.Struct)]out object obj); > > >@@ -106,109 +111,109 @@ > > public delegate int VarRefFunc (VarEnum vt, [MarshalAs (UnmanagedType.Struct)] ref object obj); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_sbyte_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_byte_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_short_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_ushort_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_int_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_uint_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_long_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_ulong_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_float_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_double_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_bstr_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_bool_true_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_in_bool_false_unmanaged (VarFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_sbyte_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_byte_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_short_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_ushort_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_int_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_uint_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_long_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_ulong_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_float_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_double_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_bstr_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_bool_true_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_variant_out_bool_false_unmanaged (VarRefFunc func); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_com_object_create (out IntPtr pUnk); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_com_object_same (out IntPtr pUnk); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_com_object_destroy (IntPtr pUnk); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_com_object_ref_count (IntPtr pUnk); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_ccw_identity ([MarshalAs (UnmanagedType.Interface)]ITest itest); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_ccw_reflexive ([MarshalAs (UnmanagedType.Interface)]ITest itest); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_ccw_transitive ([MarshalAs (UnmanagedType.Interface)]ITest itest); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITest itest); > >- [DllImport ("libtest")] >+ [DllImport (libName)] > public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITestPresSig itest); > > public static int Main() { >@@ -408,6 +413,7 @@ > return 173; > > #endregion // Runtime Callable Wrapper Tests >+ } > > #region COM Callable Wrapper Tests > >@@ -423,7 +429,6 @@ > mono_test_marshal_ccw_itest (test_pres_sig); > > #endregion // COM Callable Wrapper Tests >- } > > return 0; > } >@@ -463,6 +468,8 @@ > [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] > void DoubleIn (double val); > [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] >+ void ArrayIn (int size, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex=0)] int[] array); >+ [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] > void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val); > [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] > void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val); >@@ -513,6 +520,9 @@ > int DoubleIn (double val); > [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] > [PreserveSig ()] >+ int ArrayIn (int size, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex=0)] int[] array); >+ [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] >+ [PreserveSig ()] > int ITestIn ([MarshalAs (UnmanagedType.Interface)]ITestPresSig val); > [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] > [PreserveSig ()] >@@ -599,6 +609,13 @@ > return 0; > } > >+ public int ArrayIn (int size, int[] array) >+ { >+ if (size != 2 || size != array.Length || array[0] != 100 || array[1] != 200) >+ return 15; >+ return 0; >+ } >+ > public int ITestIn ([MarshalAs (UnmanagedType.Interface)]ITestPresSig val) > { > if (val == null) >@@ -695,6 +712,12 @@ > val = new ManagedTest (); > } > >+ public void ArrayIn (int size, int[] array) >+ { >+ if (size != 2 || size != array.Length || array[0] != 100 || array[1] != 200) >+ status = 15; >+ } >+ > public ITest Test > { > get >Index: mono/mono/tests/libtest.c >=================================================================== >--- mono.orig/mono/tests/libtest.c 2009-01-12 15:04:18.000000000 +0100 >+++ mono/mono/tests/libtest.c 2009-01-12 18:17:45.000000000 +0100 >@@ -10,6 +10,8 @@ > #ifdef WIN32 > #include <windows.h> > #include "initguid.h" >+#else >+#include <stdint.h> > #endif > > #ifdef WIN32 >@@ -2718,6 +2720,24 @@ > return 0; > return 1; > } >+#endif //NOT YET >+ >+#ifndef WIN32 >+typedef int64_t LONGLONG; >+typedef uint64_t ULONGLONG; >+typedef struct >+{ >+ uint32_t Data1; // 32 bit >+ uint16_t Data2; // 16 bit >+ uint16_t Data3; // 16 bit >+ unsigned char Data4[8]; >+} GUID; >+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ >+ const GUID name \ >+ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } >+#define S_OK 0L >+#define E_NOINTERFACE 0x80004002L >+#endif // !WIN32 > > typedef struct MonoComObject MonoComObject; > >@@ -2737,6 +2757,7 @@ > int (STDCALL *ULongIn)(MonoComObject* pUnk, ULONGLONG a); > int (STDCALL *FloatIn)(MonoComObject* pUnk, float a); > int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a); >+ int (STDCALL *ArrayIn)(MonoComObject* pUnk, int size, int* array); > int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2); > int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk); > } MonoIUnknown; >@@ -2842,6 +2863,12 @@ > return S_OK; > } > >+LIBTEST_API int STDCALL >+ArrayIn(MonoComObject* pUnk, int size, int* array) >+{ >+ return S_OK; >+} >+ > LIBTEST_API int STDCALL > ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2) > { >@@ -2879,6 +2906,7 @@ > (*pOut)->vtbl->ULongIn = ULongIn; > (*pOut)->vtbl->FloatIn = FloatIn; > (*pOut)->vtbl->DoubleIn = DoubleIn; >+ (*pOut)->vtbl->ArrayIn = ArrayIn; > (*pOut)->vtbl->ITestIn = ITestIn; > (*pOut)->vtbl->ITestOut = ITestOut; > (*pOut)->vtbl->get_ITest = get_ITest; >@@ -2925,6 +2953,7 @@ > mono_test_marshal_ccw_itest (MonoComObject *pUnk) > { > int hr = 0; >+ int array[2] = {100, 200}; > MonoComObject* pTest; > > if (!pUnk) >@@ -2960,19 +2989,21 @@ > hr = pUnk->vtbl->DoubleIn (pUnk, 3.14); > if (hr != 0) > return 11; >+ > hr = pUnk->vtbl->ITestIn (pUnk, pUnk); > if (hr != 0) > return 12; > hr = pUnk->vtbl->ITestOut (pUnk, &pTest); > if (hr != 0) > return 13; >+ hr = pUnk->vtbl->ArrayIn (pUnk, 2, array); >+ if (hr != 0) >+ return 14; > > return 0; > } > > >-#endif //NOT_YET >- > > /* > * mono_method_get_unmanaged_thunk tests
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 465825
: 264847 |
264850