[Mono-bugs] [Bug 42569][Nor] New - Mono does not properly marshal P/Invoke return type

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 8 May 2003 01:48:34 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mathpup@mylinuxisp.com.

http://bugzilla.ximian.com/show_bug.cgi?id=42569

--- shadow/42569	Thu May  8 01:48:34 2003
+++ shadow/42569.tmp.29064	Thu May  8 01:48:34 2003
@@ -0,0 +1,60 @@
+Bug#: 42569
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mathpup@mylinuxisp.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono does not properly marshal P/Invoke return type
+
+Description of Problem: 
+ 
+I have a C++ function that returns a pointer to a struct, and I'm calling it from C# 
+using P/Invoke, where the return type is a C# class set up to mirror the layout of the 
+C++ struct. The values of the C# class's fields end up corrupted. 
+ 
+The test case uses a C++ and C# program, so I'm attaching them to the bug report 
+instead of placing them inline. 
+ 
+Steps to reproduce the problem: 
+1. Compile the C++ component: g++ -shared -o libcheck.so check.cpp 
+2. Compile the C# component: mcs check.cs 
+3. Run the assembly: mono check.exe 
+ 
+ 
+Actual Results: 
+ 
+C++ has vectorList.a = 1234 
+C++ has &vectorList = 0x80ef858 
+C++ getVectorList() returns 0x80ef858 
+C# has v.a = 0 
+C# has v.b = 16842752 
+ 
+ 
+Expected Results: 
+ 
+C++ has vectorList.a = 1234 
+C++ has &vectorList = 0x808b1f0 
+C++ getVectorList() returns 0x808b1f0 
+C# has v.a = 1234 
+C# has v.b = 3 
+ 
+ 
+How often does this happen?  
+ 
+Always 
+ 
+ 
+Additional Information: 
+ 
+The output for "expected results" was obtained using Rotor on Linux. Pnet also 
+produces the same output as Rotor.