{"record":{"id":"029a731d57a876f8","repo":"Tencent/matrix","slug":"accept-primitive-array-failed-lost-type-def-of-ty","errorCode":null,"errorMessage":"accept primitive array failed, lost type def of typeId: ","messagePattern":"accept primitive array 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/HprofReader.java","lineNumber":362,"sourceCode":"        final ID id = IOUtil.readID(mStreamIn, mIdSize);\n        final int stackId = IOUtil.readBEInt(mStreamIn);\n        final int numElements = IOUtil.readBEInt(mStreamIn);\n        final ID typeId = IOUtil.readID(mStreamIn, mIdSize);\n        final int remaining = numElements * mIdSize;\n        final byte[] elements = new byte[remaining];\n        IOUtil.readFully(mStreamIn, elements, 0, remaining);\n        hdv.visitHeapDumpObjectArray(id, stackId, numElements, typeId, elements);\n        return mIdSize + 4 + 4 + mIdSize + remaining;\n    }\n\n    private int acceptPrimitiveArrayDump(int tag, HprofHeapDumpVisitor hdv) throws IOException {\n        final ID id = IOUtil.readID(mStreamIn, mIdSize);\n        final int stackId = IOUtil.readBEInt(mStreamIn);\n        final int numElements = IOUtil.readBEInt(mStreamIn);\n        final int typeId = mStreamIn.read();\n        final Type type = Type.getType(typeId);\n        if (type == null) {\n            throw new IllegalStateException(\"accept primitive array failed, lost type def of typeId: \" + typeId);\n        }\n        final int remaining = numElements * type.getSize(mIdSize);\n        final byte[] elements = new byte[remaining];\n        IOUtil.readFully(mStreamIn, elements, 0, remaining);\n        hdv.visitHeapDumpPrimitiveArray(tag, id, stackId, numElements, typeId, elements);\n        return mIdSize + 4 + 4 + 1 + remaining;\n    }\n\n    private int acceptJniMonitor(HprofHeapDumpVisitor hdv) throws IOException {\n        final ID id = IOUtil.readID(mStreamIn, mIdSize);\n        final int threadSerialNumber = IOUtil.readBEInt(mStreamIn);\n        final int stackDepth = IOUtil.readBEInt(mStreamIn);\n        hdv.visitHeapDumpJniMonitor(id, threadSerialNumber, stackDepth);\n        return mIdSize + 4 + 4;\n    }\n\n    private int skipValue() throws IOException {\n        final int typeId = mStreamIn.read();","sourceCodeStart":344,"sourceCodeEnd":380,"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/HprofReader.java#L344-L380","documentation":"HprofReader.acceptPrimitiveArrayDump() reads a primitive array record's element type byte and resolves it via Type.getType(typeId) to compute element size. An unknown type byte yields a null Type, and the reader throws IllegalStateException because it cannot determine how many bytes of element data to read.","triggerScenarios":"acceptPrimitiveArrayDump() encounters a PRIMITIVE ARRAY DUMP record whose type byte is not a valid hprof primitive type — corrupted dump or a stream desynchronized by earlier mis-parsing.","commonSituations":"Truncated hprof after interrupted device pull; parser mismatch with newer ART dump format; stream misalignment from an earlier bad record length.","solutions":["Re-capture the heap dump and verify the transfer completed (file size/checksum).","Update Matrix to support the ART/hprof version that produced the dump.","Check for and fix earlier parse desynchronization (bad idSize, unknown tags) upstream.","Catch IllegalStateException and fall back to handling the raw hprof without the shrink step."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (file.length() == 0 || !file.canRead()) {\n    throw new IOException(\"hprof missing or unreadable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    hprofReader.accept(visitor);\n} catch (IllegalStateException e) {\n    Log.e(TAG, \"primitive array parse failed; dump may be corrupt\", e);\n}","preventionTips":["Verify hprof transfers complete before parsing (size/checksum).","Keep the parser's hprof version support aligned with target devices.","Fall back to raw hprof handling when the shrink step throws."],"tags":["android","hprof","parser","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"}