Skip to content

Commit c3a8740

Browse files
[release/8.0] [Mono] Fix unsafe accessor related issue for full AOT (#91270)
* Fix unsafe accessor related issue for full aot * Only skip for WRAPPER_SUBTYPE_UNSAFE_ACCESSOR --------- Co-authored-by: Fan Yang <[email protected]>
1 parent 2ec0bc7 commit c3a8740

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/mono/mono/mini/aot-compiler.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,10 +3844,12 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8
38443844
else if (info->subtype == WRAPPER_SUBTYPE_UNSAFE_ACCESSOR) {
38453845
encode_method_ref (acfg, info->d.unsafe_accessor.method, p, &p);
38463846
encode_value (info->d.unsafe_accessor.kind, p, &p);
3847-
/* WISH: is there some kind of string heap token we could use here? */
3848-
uint32_t len = (uint32_t) strlen (info->d.unsafe_accessor.member_name);
3849-
encode_value (len, p, &p);
3850-
encode_string (info->d.unsafe_accessor.member_name, p, &p);
3847+
if (info->d.unsafe_accessor.member_name) {
3848+
/* WISH: is there some kind of string heap token we could use here? */
3849+
uint32_t len = (uint32_t) strlen (info->d.unsafe_accessor.member_name);
3850+
encode_value (len, p, &p);
3851+
encode_string (info->d.unsafe_accessor.member_name, p, &p);
3852+
}
38513853
}
38523854
else if (info->subtype == WRAPPER_SUBTYPE_INTERP_IN)
38533855
encode_signature (acfg, info->d.interp_in.sig, p, &p);

src/mono/mono/mini/method-to-ir.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6452,8 +6452,18 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
64526452
generic_context = &generic_container->context;
64536453
cfg->generic_context = generic_context;
64546454

6455-
if (!cfg->gshared)
6456-
g_assert (!sig->has_type_parameters);
6455+
if (!cfg->gshared) {
6456+
gboolean check_type_parameter = TRUE;
6457+
if (method->wrapper_type == MONO_WRAPPER_OTHER) {
6458+
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
6459+
g_assert (info);
6460+
if (info->subtype == WRAPPER_SUBTYPE_UNSAFE_ACCESSOR)
6461+
check_type_parameter = FALSE;
6462+
}
6463+
6464+
if (check_type_parameter)
6465+
g_assert (!sig->has_type_parameters);
6466+
}
64576467

64586468
if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
64596469
g_assert (method->is_inflated);

0 commit comments

Comments
 (0)