{"record":{"id":"908756b3ffafe47a","repo":"aeron-io/aeron","slug":"aeron-error-code-malformed-command","errorCode":"AERON_ERROR_CODE_MALFORMED_COMMAND","errorMessage":"command={msg_type_id} too short: length={length}","messagePattern":"command=(.+?) too short: length=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/c/aeron_driver_conductor.c","lineNumber":3214,"sourceCode":"        }\n\n        default:\n            AERON_SET_ERR(-AERON_ERROR_CODE_UNKNOWN_COMMAND_TYPE_ID, \"command=%d unknown\", msg_type_id);\n            aeron_driver_conductor_log_error(conductor);\n            break;\n    }\n\n    if (result < 0)\n    {\n        aeron_driver_conductor_on_error(conductor, aeron_errcode(), aeron_errmsg(), correlation_id);\n    }\n\n    return AERON_RB_CONTINUE;\n\nmalformed_command:\n    AERON_SET_ERR(\n        -AERON_ERROR_CODE_MALFORMED_COMMAND, \"command=%d too short: length=%\" PRIu64, msg_type_id, (uint64_t)length);\n    aeron_driver_conductor_log_error(conductor);\n\n    return AERON_RB_CONTINUE;\n}\n\nvoid aeron_driver_conductor_on_command_queue(void *clientd, void *item)\n{\n    aeron_command_base_t *cmd = (aeron_command_base_t *)item;\n    cmd->func(clientd, cmd);\n}\n\nvoid aeron_driver_conductor_on_check_for_blocked_driver_commands(aeron_driver_conductor_t *conductor, int64_t now_ns)\n{\n    int64_t consumer_position = aeron_mpsc_rb_consumer_position(&conductor->to_driver_commands);\n\n    if (consumer_position == conductor->last_command_consumer_position &&\n        aeron_mpsc_rb_producer_position(&conductor->to_driver_commands) > consumer_position)\n    {\n        int64_t position_change_deadline_ns = conductor->time_of_last_to_driver_position_change_ns +","sourceCodeStart":3196,"sourceCodeEnd":3232,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/c/aeron_driver_conductor.c#L3196-L3232","documentation":"The C media driver's conductor command loop read a command whose record length is shorter than the minimum required for the given msg_type_id (or invalid overall). It sets AERON_ERROR_CODE_MALFORMED_COMMAND, logs 'command=%d too short: length=%llu', and skips the message by continuing the ring-buffer reader.","triggerScenarios":"A writer advanced the ring buffer with a truncated record (wrote length header without the full payload), a corrupted /dev/shm file, or a client with mismatched struct packing/protocol version sending commands the driver considers too small.","commonSituations":"Crashed client leaving a partially written command; version mismatch between client and driver struct layouts; manual tooling or memory corruption modifying the shared-memory command buffer.","solutions":["Restart both driver and clients with matching Aeron versions so record layouts agree.","Remove stale shared-memory files (/dev/shm/aeron-*) and recreate them via a fresh driver start.","Fix the producer to always write the full command record before committing the length/commit position.","Check for compiler struct-packing or ABI differences if embedding the C driver/client in the same process."],"exampleFix":"// before: committing before the payload is fully written\natomic_inc(&rb->tail, record_length);\n// after: write full record, memory barrier, then commit length\nmemcpy(rec->data, cmd, cmd_len);\nrelease_fence();\nrec->length = (int32_t)record_length;","handlingStrategy":"try-catch","validationCode":"size_t min_len = aeron_driver_command_min_length(msg_type_id); if (length < min_len) { fprintf(stderr, \"refusing to send command %lld: len %llu < %zu\\n\", (long long)msg_type_id, length, min_len); abort(); }","typeGuard":"static bool command_record_is_complete(const uint8_t *rec, size_t len, size_t expected) { return len >= expected && rec != NULL; }","tryCatchPattern":"if (aeron_errcode() == -AERON_ERROR_CODE_MALFORMED_COMMAND) { fprintf(stderr, \"malformed command in ring buffer: %s\\n\", aeron_errmsg()); /* halt writer, recreate buffers */ } else if (aeron_errcode() != 0) { fprintf(stderr, \"aeron error: %s\\n\", aeron_errmsg()); }","preventionTips":["Always write the complete command record before publishing the length/tail.","Keep client and driver struct layouts identical (same version, same ABI).","Recreate shared-memory buffers after a crashed producer instead of reusing them.","Add checksum/size assertions in custom writers of the command ring buffer."],"tags":["c","aeron-driver","ipc","malformed-command"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}