[Mono-dev] crash on first runtime_invoke (using MSVC build)

Zoltan Varga vargaz at gmail.com
Sat Jan 15 16:42:56 EST 2011


Looks ok.

       Zoltan

On Sat, Jan 15, 2011 at 8:25 PM, Robert Jordan <robertj at gmx.net> wrote:

> Hi,
>
> On 15.01.2011 01:20, Zoltan Varga wrote:
> > Hi,
> >
> >    Do you have a testcase, or does this happen with all apps ?
>
>
> See mono/tests/delegate1.cs
>
> csig->pinvoke = 1 leads to STDCALL under Windows. This means
> that the "runtime_invoke" declaration in
> mini.c:mono_jit_runtime_invoke is incorrect:
>
>        MonoObject *(*runtime_invoke) (MonoObject *this, void **params,
> MonoObject **exc, void* compiled_method);
>
> should be
>
>        MonoObject *(__stdcall *runtime_invoke) (MonoObject *this, void
> **params, MonoObject **exc, void* compiled_method);
>
>
> A proposed patch (IMO, this is less uglier than injecting a conditional
> __stdcall in mono_jit_runtime_invoke()):
>
>
> diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c
> index 4c52421..2f02a4d 100644
> --- a/mono/metadata/marshal.c
> +++ b/mono/metadata/marshal.c
> @@ -4594,6 +4594,9 @@ mono_marshal_get_runtime_invoke (MonoMethod
> *method, gboolean virtual)
>         csig->params [2] = &mono_defaults.int_class->byval_arg;
>        csig->params [3] = &mono_defaults.int_class->byval_arg;
>        csig->pinvoke = 1;
> +#if TARGET_WIN32
> +       csig->call_convention = MONO_CALL_C;
> +#endif
>
>        name = mono_signature_to_name (callsig, virtual ?
> "runtime_invoke_virtual" : "runtime_invoke");
>        mb = mono_mb_new (target_klass, name,  MONO_WRAPPER_RUNTIME_INVOKE);
>
>
>
> Robert
>
>
> >
> >                     Zoltan
> >
> > On Fri, Jan 14, 2011 at 10:58 PM, Virgile Bello<virgile.bello at gmail.com
> >wrote:
> >
> >> Recently, I had some problem with the VS2010 build of mono.
> >> Runtime check complains ESP is wrong after first time runtime_invoke is
> >> called.
> >>
> >> I traced it back to this single-line commit.
> >> (Reverting this single line avoids the problem on any version up to
> master)
> >>
> >> 08f0bcaad89540260323f24811cbf896cfe471ed
> >>
> >>     Mark runtime invoke wrappers as pinvoke, since they are called from
> >> native code.
> >>
> >> diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c
> >> index 476d129..c586555 100644
> >> --- a/mono/metadata/marshal.c
> >> +++ b/mono/metadata/marshal.c
> >> @@ -4571,6 +4571,7 @@ mono_marshal_get_runtime_invoke (MonoMethod
> *method,
> >> gboolean virtual)
> >>          csig->params [1] =&mono_defaults.int_class->byval_arg;
> >>          csig->params [2] =&mono_defaults.int_class->byval_arg;
> >>          csig->params [3] =&mono_defaults.int_class->byval_arg;
> >> +       csig->pinvoke = 1;
> >>
> >>          name = mono_signature_to_name (callsig, virtual ?
> >> "runtime_invoke_virtual" : "runtime_invoke");
> >>          mb = mono_mb_new (target_klass, name,
> >>   MONO_WRAPPER_RUNTIME_INVOKE);
> >>
> >> _______________________________________________
> >> Mono-devel-list mailing list
> >> Mono-devel-list at lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >>
> >>
> >
> >
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110115/7b3bb057/attachment-0001.html 


More information about the Mono-devel-list mailing list