[Mono-bugs] [Bug 590014] New: Struct with linear layout containing IntPtr is not marshaled properly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Mar 21 06:47:23 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=590014

http://bugzilla.novell.com/show_bug.cgi?id=590014#c0


           Summary: Struct with linear layout containing IntPtr is not
                    marshaled properly
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.6.x
          Platform: x86
        OS/Version: openSUSE 11.3
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: pavel.savara at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=349655)
 --> (http://bugzilla.novell.com/attachment.cgi?id=349655)
Contains code and test to reproduce the problem

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.8)
Gecko/20100202 Firefox/3.5.8

Full source for the test attached.

C#
[StructLayout(LayoutKind.Sequential)]
public struct IntPtrHandle
{
    public IntPtr Handle;
}

[DllImport("dummy.so")]
static extern IntPtrHandle jni4net_zero();

// this returns uninitialized data
// should return Zero
// this works with MS.NET
IntPtrHandle test0 = jni4net_zero();


C/C++
void* jni4net_zero()
{
    return NULL;
} 

Reproducible: Always

Steps to Reproduce:
1. unzip attachment
2. call comp script to compile
3. call test script to execute
Actual Results:  
------------------------ struct ----------------------------
struct 0 IntPtr.Zero failed-1080660072
-1080660212
struct 1 IntPtr.Zero failed-1080660072
-1080660212
struct 2 IntPtr.One failed-1080660072
-1080660188
struct 3 IntPtr.Zero failed137681024
-1080660188
struct 4 IntPtr.One failed494976
++++++++++++++++++++++++ struct ++++++++++++++++++++++++++++


Expected Results:  
it should marshal the structure properly same way as MS.NET does

------------------------ struct ----------------------------
0
1
0
1
++++++++++++++++++++++++ struct ++++++++++++++++++++++++++++

-- 
Configure bugmail: http://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