[Mono-bugs] [Bug 467212] New: Mono runtime incorrectly calls MarshalNativeToManaged method of custom marshaler when marshaling Array argument to C++ method using PInvoke

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jan 18 16:24:46 EST 2009


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


           Summary: Mono runtime incorrectly calls MarshalNativeToManaged
                    method of custom marshaler when marshaling Array
                    argument to C++ method using PInvoke
    Classification: Mono
           Product: Mono: Runtime
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mtraudt at quantifisolutions.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=265901)
 --> (https://bugzilla.novell.com/attachment.cgi?id=265901)
Code sample that can be used to reproduce the problem

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1;
NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.21022; .NET CLR 3.5.30729;
NET CLR 3.0.30618)

In the attached test case, I am calling a C++ method that takes a user-defined
C++ array type as an argument.  I have a custom marshaler that marshals a C#
double[] to a C++ Array<double>.

With MS CLR, when calling this method, the MarshalManagedToNative method of my
custom marshaler is called, as expected.  With Mono, the MarshalNativeToManaged
method will also be called.

I think I understand the rationale behind the Mono behavior, however I assume
that the goal is to match the MS behavior as closely as possible.  Also, in my
case the MS approach is more efficient, since since my custom marshaler already
ensures pass-by-ref semantics.



Reproducible: Always

Steps to Reproduce:
1. Unzip the attached test case on Windows
2. Compile in a VS2005 or VS2008 command shell
3. Run with MS CLR, and again with Mono CLR

I tried to make it as easy as possible to build and run.  I used GNU Make
because I find it simpler for test cases.  If you need a VS project file, or
you want a Makefile that will work on Linux with Mono/GCC, let me know.

We noticed the issue originally on openSUSE11.0 with Mono2.2 and GCC4.3, but as
noted the issue is with the Mono CLR and so I decided to create my test case
entirely on Windows.

Actual Results:  
Build Program.exe and CppLibrary.dll.  When running Program.exe, you should see
that with Mono, ArrayOfDoubleMarshaler.MarshalNativeToManaged is called, but on
MS it is not.


Expected Results:  
I am expecting (hoping) to get the same behavior with Mono as with MS.


This is a critical problem for us, as we rely on the MS behavior (for reasons
that go beyond what is demonstrated in the simplified test case attached).

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