{"record":{"id":"d0823e7819e9a8d9","repo":"Tencent/matrix","slug":"visit-string-instance-failed-lost-type-def-of-typ","errorCode":null,"errorMessage":"visit string instance failed, lost type def of typeId: ","messagePattern":"visit string instance failed, lost type def of typeId: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofBufferShrinker.java","lineNumber":292,"sourceCode":"                                } else if (bufferId == null || isRecycled == null) {\n                                    IOUtil.skipValue(bais, fieldType, mIdSize);\n                                } else {\n                                    break;\n                                }\n                            }\n                            bais.close();\n                            final boolean reguardAsNotRecycledBmp = (isRecycled == null || !isRecycled);\n                            if (bufferId != null && reguardAsNotRecycledBmp && !bufferId.equals(mNullBufferId)) {\n                                mBmpBufferIds.add(bufferId);\n                            }\n                        } else if (mStringClassId != null && mStringClassId.equals(typeId)) {\n                            ID strValueId = null;\n                            final ByteArrayInputStream bais = new ByteArrayInputStream(instanceData);\n                            for (Field field : mStringClassInstanceFields) {\n                                final ID fieldNameStringId = field.nameId;\n                                final Type fieldType = Type.getType(field.typeId);\n                                if (fieldType == null) {\n                                    throw new IllegalStateException(\"visit string instance failed, lost type def of typeId: \" + field.typeId);\n                                }\n                                if (mValueFieldNameStringId.equals(fieldNameStringId)) {\n                                    strValueId = (ID) IOUtil.readValue(bais, fieldType, mIdSize);\n                                } else if (strValueId == null) {\n                                    IOUtil.skipValue(bais, fieldType, mIdSize);\n                                } else {\n                                    break;\n                                }\n                            }\n                            bais.close();\n                            if (strValueId != null && !strValueId.equals(mNullBufferId)) {\n                                mStringValueIds.add(strValueId);\n                            }\n                        }\n                    } catch (Throwable thr) {\n                        throw new RuntimeException(thr);\n                    }\n                }","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/hproflib/HprofBufferShrinker.java#L274-L310","documentation":"When visiting a String instance in the heap dump, HprofBufferShrinker looks up each field's Type by typeId to locate the `value` field. If the hprof lacks a type definition for a field's typeId, Type.getType returns null and the parser throws IllegalStateException rather than reading stream data with an unknown size, which would desynchronize the whole parse.","triggerScenarios":"Parsing an hprof whose mStringClassInstanceFields contains a Field with an unresolvable typeId — corrupted/truncated dump or a type-id table produced by an incompatible runtime.","commonSituations":"Hprof captured on an ART version with changed String internals and parsed with an outdated Matrix; truncated hprof files; dumps patched or post-processed by other tools.","solutions":["Re-capture the hprof from the same device/runtime and re-run the shrink/parse.","Upgrade Matrix so its Type/constant tables match the ART version that produced the dump.","Validate the hprof with a standard hprof parser before feeding it to Matrix.","Catch IllegalStateException around parsing and report the dump as unreadable instead of crashing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (hprofFile.length() == 0) {\n    throw new IOException(\"empty hprof: \" + hprofFile);\n}","typeGuard":null,"tryCatchPattern":"try {\n    reader.accept(visitor);\n} catch (IllegalStateException e) {\n    Log.e(TAG, \"string instance parse failed\", e);\n}","preventionTips":["Verify complete file transfer (checksum) before parsing.","Pin Matrix version compat with the runtime that produced dumps.","Validate dumps with an independent hprof parser in CI."],"tags":["android","hprof","memory-analysis","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}