Skip to content

Commit 1a37caf

Browse files
authored
[mono][tests] Using a literal field with stdsfld/ldsfld should trigger a MissingFieldException (#79160)
1 parent 5f51269 commit 1a37caf

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/mono/mono/mini/interp/transform.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4154,6 +4154,12 @@ interp_emit_sfld_access (TransformData *td, MonoClassField *field, MonoClass *fi
41544154
MonoVTable *vtable = mono_class_vtable_checked (m_field_get_parent (field), error);
41554155
return_if_nok (error);
41564156

4157+
MonoType *ftype = mono_field_get_type_internal (field);
4158+
if (ftype->attrs & FIELD_ATTRIBUTE_LITERAL) {
4159+
mono_error_set_generic_error (error, "System", "MissingFieldException", "Using static instructions with literal field");
4160+
return;
4161+
}
4162+
41574163
if (mono_class_field_is_special_static (field)) {
41584164
guint32 offset = GPOINTER_TO_UINT (mono_special_static_field_get_offset (field, error));
41594165
mono_error_assert_ok (error);
@@ -4191,7 +4197,6 @@ interp_emit_sfld_access (TransformData *td, MonoClassField *field, MonoClass *fi
41914197
if (mt == MINT_TYPE_VT)
41924198
size = mono_class_value_size (field_class, NULL);
41934199
if (is_load) {
4194-
MonoType *ftype = mono_field_get_type_internal (field);
41954200
if (ftype->attrs & FIELD_ATTRIBUTE_INIT_ONLY && vtable->initialized) {
41964201
if (interp_emit_load_const (td, field_addr, mt))
41974202
return;

src/tests/issues.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,9 +2213,6 @@
22132213
<ExcludeList Include = "$(XunitTestBinBase)/JIT/jit64/verif/sniff/fg/ver_fg_13/**">
22142214
<Issue>https://github.com/dotnet/runtime/issues/54396</Issue>
22152215
</ExcludeList>
2216-
<ExcludeList Include = "$(XunitTestBinBase)/Loader/classloader/Statics/Misc/LiteralStatic/**">
2217-
<Issue>https://github.com/dotnet/runtime/issues/54560</Issue>
2218-
</ExcludeList>
22192216
<ExcludeList Include = "$(XunitTestBinBase)/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b59952/b59952/**">
22202217
<Issue>needs triage</Issue>
22212218
</ExcludeList>

0 commit comments

Comments
 (0)