From: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Jul 2022 17:55:23 +0000 (-0500) Subject: [mono] Avoid calling mono_metadata_type_hash () on the container class in mono_generi... X-Git-Tag: accepted/tizen/unified/20221103.165808~112^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77fb0b2a314a42bc4238a557e75391abaa477304;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [mono] Avoid calling mono_metadata_type_hash () on the container class in mono_generic_class_hash (). (#71764) If a class inherits from a generic instance instantiated with itself, then its possible for mono_generic_class_hash () to be called while the container class is not fully initialized yet, i.e. byval_arg.type is 0. This would cause the generic class to change its hash. Fixes https://github.com/dotnet/runtime/issues/71424. Co-authored-by: Zoltan Varga --- diff --git a/src/mono/mono/metadata/metadata.c b/src/mono/mono/metadata/metadata.c index 1e3cd55..c16b320 100644 --- a/src/mono/mono/metadata/metadata.c +++ b/src/mono/mono/metadata/metadata.c @@ -1923,7 +1923,7 @@ static guint mono_generic_class_hash (gconstpointer data) { const MonoGenericClass *gclass = (const MonoGenericClass *) data; - guint hash = mono_metadata_type_hash (m_class_get_byval_arg (gclass->container_class)); + guint hash = mono_metadata_str_hash (m_class_get_name (gclass->container_class)); hash *= 13; hash += gclass->is_tb_open;