[Mono-bugs] [Bug 58881][Maj] Changed - [patch] marshalling of struct params to functions passed as unmanaged delegates broken
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 26 May 2004 21:36:26 -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 vladimir@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=58881
--- shadow/58881 2004-05-26 16:36:39.000000000 -0400
+++ shadow/58881.tmp.21777 2004-05-26 21:36:26.000000000 -0400
@@ -141,6 +141,23 @@
managed delegate, the unmanaged code never gets those modifications (i
and j == 0 after return from invoking the managed delegate). The
runtime never copies the contents back, I assume because it's treating
the ref SomeStruct as [In] only? (I assume that ref should imply
In/Out; otherwise, you have different behaviour depending on whether
your ref argument is blittable or not.)
+
+------- Additional Comments From vladimir@pobox.com 2004-05-26 21:36 -------
+This is related to struct layout alignment; according to
+http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeinteropservicesstructlayoutattributeclasspacktopic.asp
+managed types have a default alignment of 8, "except for unmanaged
+structures that typically have a default packing size of 4." I'm not
+sure how their runtime decides what an "unmanaged structure" is.
+We're trying to blit types that have a managed alignment of 8 to
+unmanaged blocks of memory with a different alignment. There's two
+fixes that I can think of -- one is to simply check if instance_size
+is different from mono_class_native_size(), and if so, set blittable
+to false. This means that we can't blit within the managed side of
+things either. The other fix is to introduce a new native_blittable
+flag within klass->marshal_info, and use that when deciding whether we
+can blit to/from unmanaged data types. I think the latter is a better
+fix.
+