[Mono-dev] HandleRef regression in mono 1.2.3

Miguel de Icaza miguel at novell.com
Sun Feb 11 07:53:48 EST 2007


Hello,

> This is... strange.
> 
> We based our code on this article:
> http://www.mono-project.com/Interop_with_Native_Libraries#GC-Safe_P.2FInvoke_code

As I said, you either were getting "lucky" and the data happened to be
in the right place at the right time, but since no support for it was in
the runtime, this would break with any slight change.

> Unfortunately, there's no edit date present. But the code using
> HandleRef _did_ work in 1.2.1 (I did not check earlier versions, I
> just checked it when my coworker said it has been broken with 1.2.3).

You were just lucky.   But I would be interested in a test case, to
examine what exactly was happening at the time.

Miguel.

> No matter how, I am glad this is fixed now :-)
> 
> On 2/11/07, Miguel de Icaza <miguel at novell.com> wrote:
> > Hello,
> >
> > > my team has been using HandleRef for marshaling (as mono
> > > http://www.mono-project.com/Interop_with_Native_Libraries and msdn
> > > http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.handleref.aspx
> > > suggest) for quite a long time. To our surprise, HandleRef no longer
> > > works with the new release of mono.
> >
> > There is no regression, since HandleRef was never implemented in the
> > Marshaller.   Either you just started using it, or you were getting
> > corrupted data all along.
> >
> > That being said, it will be available in Mono 1.2.4, I have just
> > implemented it.
> >
> > > Everything works fine with 2.0 profile. On 1.0, when I pass a
> > > HandleRef to a native library expecting a pointer, marshaller feeds
> > > garbage to the native code. The problem occurs both on linux and
> > > windows. And yes, I can work around this problem by replacing
> > > HandleRef by plain IntPtr's, but that's not the point, is it?
> > >
> > > I was also quite surprised by this bugzilla entry:
> > > http://bugzilla.ximian.com/show_bug.cgi?id=80515 Does this mean that
> > > the maintainer of interop stack is aware of the regression?
> >
> > I only recently discovered that we lacked support for this (while going
> > through some Moma reports, as a couple of P/Invoke signatures had it,
> > and I found out we did not support it).
> >
> > Miguel.
> >
> 
> 



More information about the Mono-devel-list mailing list