[Mono-dev] Linear layout struct containing IntPtr is not marshaled properly
Robert Jordan
robertj at gmx.net
Sun Mar 21 08:18:42 EDT 2010
On 21.03.2010 12:23, Pavel Šavara wrote:
> Hello Mono people,
>
> I work on FOSS inter-process bridge between JVM& CLR. See
> http:\\jni4net.sf.net if you are interested.
> Till now it works just on Windows and I started working on Mono
> support recently.
> I identified few Mono bugs, but one of them is blocker for me.
> https://bugzilla.novell.com/show_bug.cgi?id=590014
I don't believe this is a bug. You're simply playing with
the fire here.
You're pretending that the p/invoke is returning a struct:
C#
static extern IntPtrHandle jni4net_zero();
but the p/invoke is actually returning a pointer:
C/C++
void* jni4net_zero()
{
return NULL;
}
This works under Windows because its ABI is returning
small structs in eax, edx. If your case, jni4net_zero ()
is leaving a NULL in eax and MS.NET's (and also Mono's
marshaller under Windows) will correctly instantiate
a struct containing this NULL value.
But this only working by accident. Any other ABI that
doesn't have these struct semantics will not work.
You can fix this by actually returning a struct
from your p/invoke.
Robert
More information about the Mono-devel-list
mailing list