Skip to content

Commit

Permalink
[mono] Don't save byref System.Void into MonoDomain::typeof_void. (
Browse files Browse the repository at this point in the history
…dotnet#40405)

`mono_type_get_object_checked` will return the `MonoReflectionType`
referred to by `MonoDomain::typeof_void` if present. If a byref
`System.Void` is stored in this field, then
`get_ContainsGenericParameters` applied to `System.Void` will loop
indefinitely, because our implementation of
`get_ContainsGenericParameters` expects `GetElementType` to yield a
`MonoReflectionType` with one layer of "type function application"
removed.

Fixes dotnet#37489.
  • Loading branch information
imhameed authored Aug 6, 2020
1 parent c8ecf55 commit 1a39b6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ mono_type_get_object_checked (MonoDomain *domain, MonoType *type, MonoError *err
res->type = type;
mono_g_hash_table_insert_internal (domain->type_hash, type, res);

if (type->type == MONO_TYPE_VOID)
if (type->type == MONO_TYPE_VOID && !type->byref)
domain->typeof_void = (MonoObject*)res;

mono_domain_unlock (domain);
Expand Down

0 comments on commit 1a39b6c

Please sign in to comment.