[Mono-bugs] [Bug 61134][Nor] Changed - GCHandle.AddrOfPinnedObject gives incorrect address for arrays
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 3 Jul 2004 17:48:50 -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=61134
--- shadow/61134 2004-07-03 17:47:46.000000000 -0400
+++ shadow/61134.tmp.10362 2004-07-03 17:48:50.000000000 -0400
@@ -1,14 +1,14 @@
Bug#: 61134
Product: Mono: Runtime
Version: unspecified
-OS:
+OS: unknown
OS Details:
Status: NEW
Resolution:
-Severity:
+Severity: Unknown
Priority: Normal
Component: misc
AssignedTo: mono-bugs@ximian.com
ReportedBy: mathpup@mylinuxisp.com
QAContact: mono-bugs@ximian.com
TargetMilestone: ---
@@ -53,6 +53,54 @@
How often does this happen?
Always
Additional Information:
+
+------- Additional Comments From mathpup@mylinuxisp.com 2004-07-03 17:48 -------
+Test file: test.c
+
+#include <stdio.h>
+
+void multiDimArrayTest( const void* array ) {
+ int i;
+ unsigned char *mdarray = (unsigned char*)array;
+
+ printf("%i %i\n", mdarray, array );
+
+ printf ("size of array[x]: %i\n", sizeof(mdarray[0]) ) ;
+ for( i=0; i<64*64*3; i++){
+ if( mdarray[i] != 0 )
+ printf( "==> array(%i) = %i\n",i, mdarray[i] );
+ }
+}
+
+
+Test file: test.cs:
+
+using System;
+using System.Runtime.InteropServices;
+
+
+public class Testing
+{
+ [DllImport("libtest.so")]
+ static extern void multiDimArrayTest( IntPtr elems );
+
+ public static void Main()
+ {
+ byte[] mdArray = new byte[64*64*3];
+ for ( int i = 1; i < mdArray.Length; i++ )
+ mdArray[i] = 0;
+
+ mdArray[1982] = 1;
+ mdArray[1983] = 2;
+
+ GCHandle handle = GCHandle.Alloc( mdArray,
+ GCHandleType.Pinned);
+
+ multiDimArrayTest( handle.AddrOfPinnedObject() );
+
+ handle.Free();
+ }
+}