[Mono-list] Native code receiving incorrect pointer addresses from custom marshaler

Patrick Hartling patrick@vrac.iastate.edu
Mon, 24 May 2004 20:41:45 -0500


This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig00EFEDC247573A882B4EAE6A
Content-Type: multipart/mixed;
 boundary="------------060707090309040602050102"

This is a multi-part message in MIME format.
--------------060707090309040602050102
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

I have run into a problem with custom marshaling of pointers being 
passed from C# to natively compiled code.  The essense of it is that my 
custom marshaler's MarshalManagedToNative() returns an address to be 
passed to a native function, but the native function always receives an 
address that is four bytes greater than what my MarshalManagedToNative() 
returned.  My code works with versions of Mono as new as 0.30.2, but it 
does not work with 0.31 or Beta 1.  It also works with the .NET 
Framework 1.0 and 1.1.

I have attached a small example that demonstrates the problem.  The code 
is culled down from what I am actually attempting to do so that it 
demonstrates the problem while still implementing the basic 
functionality that I need.  With Mono 0.31 and Beta 1, the native 
function handleBase() determines that the pointer passed into it from 
the managed environment does not match the pointer allocated by new_Base().

As I said, the value is consistently off by four bytes, but only when a 
custom marshaler is involved.  Has there been a semantic change in Mono 
that I need to take into account, or (worst case for me) has my code 
been flawed from the beginning?

  -Patrick


-- 
Patrick L. Hartling                     | Research Assistant, VRAC
patrick@vrac.iastate.edu                | 2274 Howe Hall Room 2624
http://www.vrac.iastate.edu/~patrick/   | http://www.vrac.iastate.edu/
PGP: http://wwwkeys.gpg.cz:11371/pks/lookup?op=get&search=0xEBF86398

--------------060707090309040602050102
Content-Type: application/x-gzip;
 name="marshal_test.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="marshal_test.tar.gz"

H4sIAOGjskAAA+1X60/jRhDna/avmEv4YJPDSSAJkg+qo4Feo/I4EShSEYocewM+7F3LdiAU
8b93dr2O7TzuWikgtfUoSpzZefx2Xt71rTC6t7xhTKO4sfE21Gy2m3udDv42W3udpvzFj/hN
aQMZnXZnp9XtdDearZ1uZ28DOm+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Ngyht
zh9cusyTn4rm7auJoRwUu2emkMyB4qoYCPPNhzM+6a81TS7ZbPcWczwqQ6T2c6NAHEbaFVPt
cPkcUGMuPEuKSK0J6Qs6RigxPvGxNhteM2Vdz400VcuLGZEITy2XaQMZ/ptbsMK7qBD+1EAu
itk0ze2OZ6nHwL6+w3Ft7VQ4/2XH17X6+MH5r9Vq5e7/XXH/b3fbzfL89x5Uc5ntTRwK+y7H
eUQt/ye8rLljB3tN3r9IDR9x/ANeZIaHX/swHDrU9qKA2hreWfDygjNDJzXq4ZlvTha5zHHH
4vqTOxYm/WiKvkmPBziYsFfF+hbc4QDWzq7w2oQsNV2qvao4ZKYQEsHsoJOMMKG42LFR7Jim
jfdE2N8HfC3W67c5TVONWjGHq0JCit/TqXiWBlMe7sSTBtVsFotynqag5kdfAlK+ql9WAcmJ
Syjq+LWARMyiIhB5SB6DJpc+HCRYC0Nsmb/ji4vzCzxiMZuHoXgNBlyetOHR8iY0A5C8OGsf
qgvzeCEc/97RV1JJJZVUUkkllVRSSSWVVFJJJZVUUkn/efoL+J94mQAoAAA=
--------------060707090309040602050102--

--------------enig00EFEDC247573A882B4EAE6A
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAsqRg5DgSg+v4Y5gRAnBnAKCiyJMx6301sQe0k83r6tPyBS2rQACgnCv9
2ESFXd9U+YJeGnqYOWghyMo=
=on1a
-----END PGP SIGNATURE-----

--------------enig00EFEDC247573A882B4EAE6A--