gchq/CyberChef · error · OperationError

Disassembly failed: ${e}

Error message

Disassembly failed: ${e}

What it means

Thrown by Disassemble ARM run() inside the disasm catch for any capstone disassembly error that is NOT the 'code 0:' (no instructions) case. The original exception is stringified. This covers genuine capstone failures during disasm(): invalid memory access in WASM, unexpected internal errors, unsupported instruction edge cases, or a thrown JS error from the binding.

Source

Thrown at src/core/operations/DisassembleARM.mjs:158

        }

        let disassembler;
        try {
            disassembler = new cs.Capstone(arch, modeValue);
        } catch (e) {
            throw new OperationError(`Failed to initialise Capstone disassembler: ${e}`);
        }

        let instructions;
        try {
            instructions = disassembler.disasm(bytes, startAddress);
        } catch (e) {
            disassembler.close();
            // Check if it's a "no valid instructions" error (code 0 means OK but nothing decoded)
            if (e && e.includes && e.includes("code 0:")) {
                throw new OperationError(`No valid ${architecture} instructions found in input. The bytes may be for a different architecture or mode.`);
            }
            throw new OperationError(`Disassembly failed: ${e}`);
        }

        // Format output
        const output = [];
        for (const insn of instructions) {
            let line = "";

            if (showPosition) {
                // Format address as hex with 0x prefix
                const addrHex = "0x" + insn.address.toString(16).padStart(8, "0");
                line += addrHex + "  ";
            }

            if (showHex) {
                // Format instruction bytes as hex
                const bytesHex = insn.bytes.map(b => b.toString(16).padStart(2, "0")).join("");
                line += bytesHex.padEnd(16, " ") + "  ";
            }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Reduce the input size and retry to rule out WASM memory limits.
  2. Verify startAddress is a sane non-negative integer.
  3. Try a different Architecture/Mode/Endianness to rule out an instruction-edge-case fault.
  4. Capture the exact exception text from the error message and report if it indicates a capstone-js binding bug.
  5. Update @alexaltea/capstone-js to the latest version.

Example fix

// before - multi-megabyte hex input exhausting WASM memory
input: <several MB of hex>

// after - disassemble in smaller chunks
input: <first 64KB of hex>
Defensive patterns

Strategy: try-catch

Validate before calling

// bound input size to avoid WASM memory exhaustion
function isReasonableInputSize(hexInput) {
    const bytes = hexInput.replace(/\s/g, "").length / 2;
    return bytes > 0 && bytes < 1_000_000; // < ~1MB
}

Type guard

/** @returns {boolean} */
function isReasonableHexInputSize(s) {
    const digits = typeof s === "string" ? s.replace(/\s/g, "").length : 0;
    return digits > 0 && digits % 2 === 0 && digits / 2 < 1_000_000;
}

Try / catch

try {
    out = await disassembleArm.run(input, args);
} catch (e) {
    if (e instanceof OperationError && /Disassembly failed/.test(e.message)) {
        // reduce input size, verify startAddress, try a different arch/mode, then retry
    } else throw e;
}

Prevention

When it happens

Trigger: disassembler.disasm(bytes, startAddress) raises with a message that does not contain 'code 0:'. Could be an out-of-range startAddress producing an internal error, a capstone internal fault, a WASM memory error on very large inputs, or an exception type without an .includes method (the guard checks e && e.includes).

Common situations: A very large input exhausting WASM linear memory; a non-string exception object from the binding (the guard's e.includes check defends this and falls through to this branch); an internal capstone bug triggered by specific byte patterns; an invalid startAddress.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/5968417c8795c01c. Report an issue: GitHub.