[Mono-bugs] [Bug 63755][Nor] New - Mono does not correctly marshal "ref string[]" for P/Invoke
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 24 Aug 2004 02:42:41 -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=63755
--- shadow/63755 2004-08-24 02:42:41.000000000 -0400
+++ shadow/63755.tmp.8241 2004-08-24 02:42:41.000000000 -0400
@@ -0,0 +1,90 @@
+Bug#: 63755
+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 correctly marshal "ref string[]" for P/Invoke
+
+Description of Problem:
+
+When a P/Invoke method has a parameter with type "ref string[]", the Mono
+runtime does not correctly marshal the data.
+
+The test programs attached print "Zebra", "Horse", and "Mule" on
+Rotor/.NET, but under Mono the result is garbage.
+
+Steps to reproduce the problem:
+1. g++ -O -o libdata.so -shared data.cpp
+2. mcs data.cs
+3. mono data.exe
+
+
+Actual Results:
+
+Unprintable character(s) are printed.
+
+
+Expected Results:
+
+Zebra
+Horse
+Mule
+
+are printed.
+
+
+How often does this happen?
+
+Always
+
+
+Additional Information:
+
+data.cs:
+
+using System;
+using System.Runtime.InteropServices;
+
+public class Tesing
+{
+ [DllImport("libdata.so", CharSet=CharSet.Ansi)]
+ private static extern int f(ref string[] data);
+
+ public static void Main()
+ {
+ string[] data = { "Zebra", "Horse", "Mule", null };
+ f(ref data);
+ }
+
+}
+
+
+data.cpp:
+
+#include <iostream>
+using namespace std;
+
+extern "C"
+{
+int f(char ***data)
+{
+ char** string_array = *data;
+ int i = 0;
+ while ( string_array[i] != 0 )
+ {
+ cout << string_array[i] << endl;
+ i++;
+ }
+}
+}