{"record":{"id":"91e11f91700123cc","repo":"Tencent/matrix","slug":"acceptheapdumprecord-loop-with-unknown-tag-hea","errorCode":null,"errorMessage":"acceptHeapDumpRecord loop with unknown tag \" + heapDumpTag + \" with \" + mStreamIn.available() + \" bytes possibly remaining","messagePattern":"acceptHeapDumpRecord loop with unknown tag \" \\+ heapDumpTag \\+ \" with \" \\+ mStreamIn\\.available\\(\\) \\+ \" bytes possibly remaining","errorType":"exception","errorClass":"IllegalArgumentException","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":222,"sourceCode":"                    length -= mIdSize;\n                    break;\n                case HprofConstants.HEAPDUMP_ROOT_REFERENCE_CLEANUP:\n                    hdv.visitHeapDumpBasicObj(heapDumpTag, IOUtil.readID(mStreamIn, mIdSize));\n                    length -= mIdSize;\n                    break;\n                case HprofConstants.HEAPDUMP_ROOT_VM_INTERNAL:\n                    hdv.visitHeapDumpBasicObj(heapDumpTag, IOUtil.readID(mStreamIn, mIdSize));\n                    length -= mIdSize;\n                    break;\n                case HprofConstants.HEAPDUMP_ROOT_JNI_MONITOR:\n                    length -= acceptJniMonitor(hdv);\n                    break;\n                case HprofConstants.HEAPDUMP_ROOT_UNREACHABLE:\n                    hdv.visitHeapDumpBasicObj(heapDumpTag, IOUtil.readID(mStreamIn, mIdSize));\n                    length -= mIdSize;\n                    break;\n                default:\n                    throw new IllegalArgumentException(\n                            \"acceptHeapDumpRecord loop with unknown tag \" + heapDumpTag\n                                    + \" with \" + mStreamIn.available()\n                                    + \" bytes possibly remaining\");\n            }\n        }\n        hdv.visitEnd();\n    }\n\n    private void acceptUnconcernedRecord(int tag, int timestamp, long length, HprofVisitor hv) throws IOException {\n        final byte[] data = new byte[(int) length];\n        IOUtil.readFully(mStreamIn, data, 0, length);\n        hv.visitUnconcernedRecord(tag, timestamp, length, data);\n    }\n\n    private int acceptHeapDumpInfo(HprofHeapDumpVisitor hdv) throws IOException {\n        final int heapId = IOUtil.readBEInt(mStreamIn);\n        final ID heapNameId = IOUtil.readID(mStreamIn, mIdSize);\n        hdv.visitHeapDumpInfo(heapId, heapNameId);","sourceCodeStart":204,"sourceCodeEnd":240,"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#L204-L240","documentation":"HprofReader.acceptHeapDumpRecord() switches on each heap dump record's tag. When the tag does not match any known HprofConstants record type, the parser throws IllegalArgumentException reporting the unknown tag and remaining bytes, because the record layout is unknown and the stream position can no longer be advanced safely.","triggerScenarios":"Parsing an hprof whose heap dump section contains a tag outside the parser's known set — dumps written by a newer ART/JVM HPROF version, or a stream already desynchronized from earlier mis-parsing.","commonSituations":"Hprof from a newer Android/JDK version than the parser supports (e.g. Android 14+ ART adding record types); parsing the 1.0.2 variant with a 1.0.1 parser; a prior bad idSize silently desynchronizing the stream.","solutions":["Upgrade Matrix so HprofConstants/acceptHeapDumpRecord covers the record tags of the runtime that produced the dump.","Capture the hprof with the standard 'am dumpheap' of the target device and re-check the dump format version in the header.","Fix any earlier parse error (e.g. bad idSize) that may have desynchronized the byte stream.","Catch IllegalArgumentException around accept() and treat the dump as unsupported rather than crashing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"String version = readHprofVersionHeader(file);\nif (!SUPPORTED_VERSIONS.contains(version)) {\n    throw new IOException(\"unsupported hprof version: \" + version);\n}","typeGuard":null,"tryCatchPattern":"try {\n    hprofReader.accept(visitor);\n} catch (IllegalArgumentException e) {\n    Log.e(TAG, \"unknown heap dump tag; hprof likely from newer runtime\", e);\n}","preventionTips":["Keep Matrix updated for new ART hprof record types.","Capture dumps with the device's own 'am dumpheap'.","Treat repeated unknown-tag errors as a format-version mismatch, not a data bug."],"tags":["android","hprof","parser","unsupported-format"],"backgroundTag":"unsupported-enum-value","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"}