{"record":{"id":"c778c97730d6d417","repo":"oracle/graal","slug":"unable-to-decode-some-instructions-in","errorCode":null,"errorMessage":"Unable to decode some instructions in ","messagePattern":"Unable to decode some instructions in ","errorType":"exception","errorClass":"InternalError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/DisassemblerTool.java","lineNumber":388,"sourceCode":"            for (DecodedInstruction insn : allInsn) {\n                int insnOffset = (int) (insn.address() - startAddress);\n                instructions.add(new DisassemblerTool.Instruction(insnOffset, insn, getOperandComments(operandComments, insn.size(), insnOffset), getComments(comments, insnOffset)));\n                currentOffset = insnOffset + insn.size();\n            }\n            if (currentOffset >= endOffset) {\n                break;\n            } else {\n                int size;\n                // Broken instruction\n                if (dis.getArchitecture().equals(Disassembler.Architecture.AArch64)) {\n                    size = 4;\n                } else if (dis.getArchitecture().equals(Disassembler.Architecture.AMD64)) {\n                    // This could potentially be handled better by splitting the machine code into\n                    // chunks in between comments and decoding those chunks independently. That\n                    // would naturally resynchronize the disassembly if problems are encountered.\n                    size = 1;\n                } else {\n                    throw new InternalError(\"Unable to decode some instructions in \" + dis.getArchitecture());\n                }\n                byte[] bytes = Arrays.copyOfRange(code, currentOffset, currentOffset + size);\n                Formatter buf = new Formatter();\n                for (byte b : bytes) {\n                    buf.format(\"%02x \", b);\n                }\n                String encoding = (size == 1 ? \".byte\\t\" : \".bytes\\t\") + buf.toString().trim();\n                DecodedInstruction insn = new DecodedInstruction(startAddress + currentOffset, size, encoding, null, bytes);\n                instructions.add(new DisassemblerTool.Instruction(currentOffset, insn,\n                                getOperandComments(operandComments, size, currentOffset), getComments(comments, currentOffset + startOffset)));\n                currentOffset += size;\n            }\n        }\n        return instructions;\n    }\n\n    private static List<String> getComments(Map<Integer, List<String>> comments, int insnOffset) {\n        if (comments != null) {","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/disassembler/DisassemblerTool.java#L370-L406","documentation":"This InternalError is thrown in DisassemblerTool's decode loop when a decode step fails and the fallback byte-emission path cannot determine a skip size because the disassembler's architecture is neither AArch64 nor AMD64. On AMD64 broken instructions are resynchronized one byte at a time and on AArch64 four bytes at a time; any other Architecture enum value has no resynchronization policy, so the tool aborts. In practice it marks an internal inconsistency: a Disassembler was constructed for an architecture the tool's repair logic does not know.","triggerScenarios":"A Disassembler.Architecture value outside {AArch64, AMD64} reaches decodeInstructions and encounters an instruction the underlying decoder fails on (broken/undecodable bytes). The size-selection if/else falls to the default branch and throws.","commonSituations":"New Architecture enum constants added without updating this repair switch, or a custom Disassembler implementation returning an unusual architecture constant. Not reachable on stock x86_64/aarch64 builds even with corrupt code bytes.","solutions":["If you added a new Architecture constant, add a resync size case for it in DisassemblerTool's broken-instruction branch.","If using a custom Disassembler, make it report AMD64 or AArch64 (whichever matches its decoding) so the fallback applies.","Fix the undecodable bytes upstream (regenerate the hex dump) so the failure branch is never entered.","Report it as a GraalVM bug if it occurs with an unmodified build — it indicates a tool/architecture mismatch."],"exampleFix":"// before\n} else {\n    throw new InternalError(\"Unable to decode some instructions in \" + dis.getArchitecture());\n}\n// after (when adding RISCV64 support)\n} else if (dis.getArchitecture().equals(Disassembler.Architecture.RISCV64)) {\n    size = 4;\n} else {\n    throw new InternalError(\"Unable to decode some instructions in \" + dis.getArchitecture());\n}","handlingStrategy":"validation","validationCode":"Disassembler.Architecture a = dis.getArchitecture();\nif (a != Disassembler.Architecture.AMD64 && a != Disassembler.Architecture.AArch64) {\n    throw new UnsupportedOperationException(\"no resync policy for \" + a);\n}","typeGuard":null,"tryCatchPattern":"try { decode(); } catch (InternalError e) { /* treat as tool limitation: report arch, fall back to raw hex dump */ }","preventionTips":["Keep the Architecture enum and this resync switch in sync when extending the enum.","Custom Disassemblers should report one of the two supported constants.","Undecodable bytes reaching this branch usually means upstream data corruption — fix the dump."],"tags":["graalvm","disassembler","internal-error","architecture"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}