Skip to content

Commit 6550988

Browse files
authored
Merge pull request #1088 from Unity-Technologies/scripting_memory_capture_metadata_crawling_fix_2018.3-mbe
[Memory Snapshot][2018.3] Metadata crawling, use only initialized types
2 parents 0efc681 + 41af94b commit 6550988

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);
@@ -184,10 +184,7 @@ AddMetadataType(gpointer key, gpointer value, gpointer user_data)
184184
MonoMetadataField *metaField = &type->fields[type->fieldCount];
185185
MonoClass *typeKlass = mono_class_from_mono_type(field->type);
186186

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

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

0 commit comments

Comments
 (0)