Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono] inflate function pointer types; hang indirect call wrappers on the <Module> #106837

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/mono/mono/metadata/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,21 @@ inflate_generic_type (MonoImage *image, MonoType *type, MonoGenericContext *cont
nt->data.type = inflated;
return nt;
}
case MONO_TYPE_FNPTR: {
MonoMethodSignature *in_sig = type->data.method;
// quick bail out - if there are no type variables anywhere in the signature,
// there's nothing that could get inflated.
if (!in_sig->has_type_parameters)
return NULL;
MonoMethodSignature *new_sig = mono_inflate_generic_signature (in_sig, context, error);
if (!new_sig || !is_ok (error))
return NULL;
if (new_sig == in_sig)
kg marked this conversation as resolved.
Show resolved Hide resolved
return type;
MonoType *nt = mono_metadata_type_dup (image, type);
nt->data.method = new_sig;
return nt;
}
lambdageek marked this conversation as resolved.
Show resolved Hide resolved
default:
if (!changed)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3963,7 +3963,7 @@ mono_marshal_get_native_func_wrapper_indirect (MonoClass *caller_class, MonoMeth
return res;

char *name = mono_signature_to_name (sig, "wrapper_native_indirect");
MonoMethodBuilder *mb = mono_mb_new (caller_class, name, MONO_WRAPPER_MANAGED_TO_NATIVE);
MonoMethodBuilder *mb = mono_mb_new (get_wrapper_target_class (image), name, MONO_WRAPPER_MANAGED_TO_NATIVE);
mb->method->save_lmf = 1;

WrapperInfo *info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NATIVE_FUNC_INDIRECT);
Expand Down
Loading