From: imhameed Date: Thu, 6 Aug 2020 00:49:12 +0000 (-0700) Subject: [mono] Don't save byref `System.Void` into `MonoDomain::typeof_void`. (#40405) X-Git-Tag: submit/tizen/20210909.063632~6194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a39b6c63dbc12721348281bd591ef5a8d75b4ae;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [mono] Don't save byref `System.Void` into `MonoDomain::typeof_void`. (#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 https://github.com/dotnet/runtime/issues/37489. --- diff --git a/src/mono/mono/metadata/reflection.c b/src/mono/mono/metadata/reflection.c index c28ce82..09851b3 100644 --- a/src/mono/mono/metadata/reflection.c +++ b/src/mono/mono/metadata/reflection.c @@ -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);