{"record":{"id":"79bdaa01458c3d9d","repo":"oracle/graal","slug":"malformed-hexcodefile-in","errorCode":null,"errorMessage":"Malformed HexCodeFile in ","messagePattern":"Malformed HexCodeFile in ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/DisassemblerTool.java","lineNumber":121,"sourceCode":"\n                String source = input.substring(codeStart, endIndex);\n\n                if (processingHotSpotAbstractAssembly) {\n                    if (dis == null) {\n                        dis = MachCode.initDisassembler(inputName, input, log, userArch);\n                    }\n                    String machCode = source.strip();\n                    FailureReason fr = new FailureReason();\n                    if (!new MachCode(dis).process(machCode, out, showComments, showBytes, fr)) {\n                        out.println(\"# Could not disassemble MachCode: \" + fr.getReason());\n                        out.println(MACHCODE_OPEN);\n                        out.println(machCode);\n                        out.println(MACHCODE_CLOSE);\n                    }\n                } else {\n                    HexCodeFile hcf = HexCodeFile.parse(input, codeStart, source, inputName);\n                    if (hcf == null) {\n                        throw new IllegalArgumentException(\"Malformed HexCodeFile in \" + inputName);\n                    }\n                    new HexCodeFileDis(showComments, showBytes).process(hcf, out);\n                }\n                count++;\n                codeEnd = endIndex;\n            }\n        }\n\n        String copy = input.substring(codeEnd);\n        if (copy.startsWith(endDelim)) {\n            copy = copy.substring(endDelim.length());\n        }\n\n        if (log != null) {\n            log.println(inputName + \": disassembled \" + count + (processingHotSpotAbstractAssembly ? \" MachCode sections\" : \" HexCodeFiles\"));\n        }\n        out.print(copy);\n        out.flush();","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/DisassemblerTool.java#L103-L139","documentation":"DisassemblerTool throws this IllegalArgumentException when HexCodeFile.parse returns null for a block delimited by the asm/hex-code markers in the input file. HexCodeFile.parse signals unrecoverable syntax problems by returning null (with diagnostics typically already emitted), and the tool converts that into an exception naming the input file. It means an embedded HexCodeFile block between the markers is not parseable as hex-plus-comment lines.","triggerScenarios":"Running the disassembler tool on a file whose \"<hexcode>\"-style block contains non-hex text, misaligned address columns, comments in an unexpected column format, or truncated content between the open and close delimiters. Only reached in the else-branch (non-MachCode input), i.e. classic HexCodeFile dumps such as IdealGraphStudio or test output.","commonSituations":"Feeding hand-edited disassembly dumps, files where line wrapping broke hex columns, or output from a different GraalVM version whose HexCodeFile comment format changed. Also when delimiters appear inside the payload, ending the block early and leaving garbage to parse.","solutions":["Inspect the named input file around the block markers and fix or remove malformed hex lines (only hex bytes, optional '#'-comment columns, consistent address column).","Re-generate the HexCodeFile with a matching GraalVM version instead of editing it by hand.","Ensure the open/close delimiters are balanced and no stray delimiter text occurs inside the code block.","Run with the tool's verbose/diagnostic options to see the parse errors HexCodeFile.parse recorded before returning null."],"exampleFix":"// before (input block)\n<hexcode>\n0x0000: 55 48 89 e5\noops this line is prose\n</hexcode>\n// after\n<hexcode>\n0x0000: 55 48 89 e5\n0x0004: c9 c3\n</hexcode>","handlingStrategy":"try-catch","validationCode":"HexCodeFile probe = HexCodeFile.parse(block, codeStart, blockText, inputName);\nif (probe == null) { /* log diagnostics, skip block, or abort with context */ }","typeGuard":null,"tryCatchPattern":"try { tool.run(inputName); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Malformed HexCodeFile\")) { /* quarantine file, continue batch */ } else throw e; }","preventionTips":["Never hand-edit hex dumps; regenerate them.","Validate blocks with HexCodeFile.parse before committing test fixtures.","When batch-processing, isolate per-file failures so one bad block does not kill the run."],"tags":["graalvm","disassembler","hexcodefile","tooling"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}