[Mono-dev] Exception in runtime-invoke Wrapper

Martin Däumler mdae at cs.tu-chemnitz.de
Mon Jan 24 10:57:41 EST 2011


On 18.01.11 12:11, Martin Däumler wrote:

> when executing mono/tests/delegate1.cs, "d.EndInvoke(ar1)" does not
> resume when the async call "d.BeginInvoke()" terminates.
>
> I guess that the problem is caused by an exception thrown by the
> wrapper used to call the setter of WaitHandle. The call stack
> (using GDB/DDD) of the call to "d.EndInvoke(ar1)" is as follows:
>
> [...]
>
> The result is, that the setter gets a wrong value. In particular,
> the setter gets the address of the handle, i.e., one dereference
> is missing.

Hello,

I investigated the problem further and it turned out that the
wrapper does not throw an exception. I misinterpreted the
debugger output.

It is a more general problem. During my pre-compilation I generate
a runtime-invoke wrapper for each method that was pre-compiled.
This generation is done by "mono_marshal_get_runtime_invoke()".
Before the wrapper for "System.Threading.WaitHandle:set_Handle()"
(which leads to the misbehaviour) is generated, one wrapper for, e.g.,
"System.Attribute:System.Runtime.InteropServices._Attribute.GetTypeInfoCount()"
or "System.Globalization.GregorianCalendar:M_CheckEra()" is generated.

This wrapper is also used for "System.Threading.WaitHandle:set_Handle()"
later, due to Mono's wrapper sharing mechanism. Unfortunately it does
not work correctly for it. I tried to reproduce the misbehaviour by
writing a test case that calls a method (e.g., one of the above
mentioned) in order to generate the "wrong" wrapper and then calls
"System.Threading.WaitHandle:set_Handle()".

But now I am not sure if these methods ever need a runtime-invoke
wrapper. So my question is: Which methods might ever need a
runtime-invoke wrapper? Or, what does a runtime-invoke
wrapper exactly do?


With kind regards,
Martin Däumler


More information about the Mono-devel-list mailing list