From 3a6ff1e5bf713772f779cb2e1399c8e4fd9ef15b Mon Sep 17 00:00:00 2001 From: Ehren Julien-Neitzert Date: Tue, 21 Mar 2023 14:07:47 -0400 Subject: [PATCH] Ignore null classes when searching the FCC Some entries in the FCC have their clazz field set to null, these null classes should not be dereferenced For #13182 (fixes error in UninitializedInlineFieldsTest, as well as other tests) Signed-off-by: Ehren Julien-Neitzert --- runtime/vm/ValueTypeHelpers.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/runtime/vm/ValueTypeHelpers.cpp b/runtime/vm/ValueTypeHelpers.cpp index cbd9b746663..d6505edd5ee 100644 --- a/runtime/vm/ValueTypeHelpers.cpp +++ b/runtime/vm/ValueTypeHelpers.cpp @@ -143,18 +143,21 @@ J9Class * findJ9ClassInFlattenedClassCache(J9FlattenedClassCache *flattenedClassCache, U_8 *className, UDATA classNameLength) { UDATA length = flattenedClassCache->numberOfEntries; - J9Class *clazz = NULL; + J9Class *foundClass = NULL; for (UDATA i = 0; i < length; i++) { - J9UTF8* currentClassName = J9ROMCLASS_CLASSNAME(J9_VM_FCC_ENTRY_FROM_FCC(flattenedClassCache, i)->clazz->romClass); - if (J9UTF8_DATA_EQUALS(J9UTF8_DATA(currentClassName), J9UTF8_LENGTH(currentClassName), className, classNameLength)) { - clazz = J9_VM_FCC_CLASS_FROM_ENTRY(J9_VM_FCC_ENTRY_FROM_FCC(flattenedClassCache, i)); - break; + J9Class *currentClass = J9_VM_FCC_CLASS_FROM_ENTRY(J9_VM_FCC_ENTRY_FROM_FCC(flattenedClassCache, i)); + if (NULL != currentClass) { + J9UTF8* currentClassName = J9ROMCLASS_CLASSNAME(currentClass->romClass); + if (J9UTF8_DATA_EQUALS(J9UTF8_DATA(currentClassName), J9UTF8_LENGTH(currentClassName), className, classNameLength)) { + foundClass = currentClass; + break; + } } } - Assert_VM_notNull(clazz); - return clazz; + Assert_VM_notNull(foundClass); + return foundClass; } UDATA