From 77fb0b2a314a42bc4238a557e75391abaa477304 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Jul 2022 12:55:23 -0500 Subject: [PATCH] [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 --- src/mono/mono/metadata/metadata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.7.4