Skip to content

Commit

Permalink
[interp] Use dynamic method's assembly when getting a native wrapper (d…
Browse files Browse the repository at this point in the history
…otnet#65320)

The dynamic method `klass` is just System.Object, so its image is always
corelib.  As a result, we incorrectly pick up the DisableRuntimeMarshalling
attribute from CoreLib.

Fixes dotnet#65304

The corresponding change to the JIT+AOT was done in
dotnet@ac825ab
  • Loading branch information
lambdageek authored Feb 14, 2022
1 parent 386c124 commit 3e5c2b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mono/mono/mini/interp/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,13 @@ mono_interp_get_native_func_wrapper (InterpMethod* imethod, MonoMethodSignature*
MonoMethodPInvoke iinfo;
memset (&iinfo, 0, sizeof (iinfo));

MonoMethod* m = mono_marshal_get_native_func_wrapper (m_class_get_image (imethod->method->klass), csignature, &iinfo, mspecs, code);
MonoMethod *method = imethod->method;
MonoImage *image = NULL;
if (imethod->method->dynamic)
image = ((MonoDynamicMethod*)method)->assembly->image;
else
image = m_class_get_image (method->klass);
MonoMethod* m = mono_marshal_get_native_func_wrapper (image, csignature, &iinfo, mspecs, code);

for (int i = csignature->param_count; i >= 0; i--)
if (mspecs [i])
Expand Down

0 comments on commit 3e5c2b9

Please sign in to comment.