Skip to content

Commit 80dbc48

Browse files
authored
Merge pull request #1086 from Unity-Technologies/scripting_memory_capture_metadata_crawling_fix
[Memory Snapshot] Metadata crawling, use only initialized types
2 parents 2bcc60e + f27e6ce commit 80dbc48

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

mono/metadata/unity-memory-info.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ContextRecurseClassData (CollectMetadataContext *context, MonoClass *klass)
3636
* If we use g_hash_table_lookup it returns the value which we were comparing to NULL. The problem is
3737
* that 0 is a valid class index and was confusing our logic.
3838
*/
39-
if (!g_hash_table_lookup_extended (context->allTypes, klass, &orig_key, &value)) {
39+
if (klass->inited && !g_hash_table_lookup_extended (context->allTypes, klass, &orig_key, &value)) {
4040
g_hash_table_insert (context->allTypes, klass, GINT_TO_POINTER (context->currentIndex++));
4141

4242
fieldCount = mono_class_num_fields (klass);
@@ -183,10 +183,7 @@ AddMetadataType (gpointer key, gpointer value, gpointer user_data)
183183
MonoMetadataField *metaField = &type->fields[type->fieldCount];
184184
MonoClass *typeKlass = mono_class_from_mono_type (field->type);
185185

186-
if (typeKlass->rank > 0)
187-
metaField->typeIndex = FindClassIndex (context->allTypes, mono_class_get_element_class (typeKlass));
188-
else
189-
metaField->typeIndex = FindClassIndex (context->allTypes, typeKlass);
186+
metaField->typeIndex = FindClassIndex (context->allTypes, typeKlass);
190187

191188
// This will happen if fields type is not initialized
192189
// It's OK to skip it, because it means the field is guaranteed to be null on any object

0 commit comments

Comments
 (0)