Ensure generic parameter constraint type is included when building image (#34346)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Wed, 1 Apr 2020 20:01:28 +0000 (16:01 -0400)
committerGitHub <noreply@github.com>
Wed, 1 Apr 2020 20:01:28 +0000 (16:01 -0400)
sets.

This fixes: https://issuetracker.unity3d.com/issues/editor-crash-when-entering-and-exiting-playmode-for-a-few-times-with-microsoft-maps-sdk

@joncham and I were working on this we hit the two asserts that I've removed. We were wondering if they were still needed?

<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->

Co-authored-by: UnityAlex <UnityAlex@users.noreply.github.com>
src/mono/mono/metadata/metadata.c

index 9ce5150..5734b9f 100644 (file)
@@ -2570,7 +2570,13 @@ retry:
                return signature_in_image (type->data.method, image);
        case MONO_TYPE_VAR:
        case MONO_TYPE_MVAR:
-               return image == mono_get_image_for_generic_param (type->data.generic_param);
+               if (image == mono_get_image_for_generic_param (type->data.generic_param))
+                       return TRUE;
+               else if (type->data.generic_param->gshared_constraint) {
+                       type = type->data.generic_param->gshared_constraint;
+                       goto retry;
+               }
+               return FALSE;
        default:
                /* At this point, we should've avoided all potential allocations in mono_class_from_mono_type_internal () */
                return image == m_class_get_image (mono_class_from_mono_type_internal (type));
@@ -3055,6 +3061,9 @@ retry:
        {
                MonoImage *image = mono_get_image_for_generic_param (type->data.generic_param);
                add_image (image, data);
+               type = type->data.generic_param->gshared_constraint;
+               if (type)
+                       goto retry;
                break;
        }
        case MONO_TYPE_CLASS: