{"record":{"id":"12987539e39fc91a","repo":"NationalSecurityAgency/ghidra","slug":"invalid-byte-order-129875","errorCode":null,"errorMessage":"Invalid byte_order: {}","messagePattern":"Invalid byte_order: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py","lineNumber":298,"sourceCode":"            f\"Address {address} is not in process {proc.GetProcessID()}\")\n\n\nDEFAULT_MEMORY_MAPPER = DefaultMemoryMapper('ram')\n\nmemory_mappers: Dict[str, DefaultMemoryMapper] = {}\n\n\ndef compute_memory_mapper(lang: str) -> DefaultMemoryMapper:\n    if not lang in memory_mappers:\n        return DEFAULT_MEMORY_MAPPER\n    return memory_mappers[lang]\n\n\nclass DefaultRegisterMapper(object):\n\n    def __init__(self, byte_order: str) -> None:\n        if not byte_order in ['big', 'little']:\n            raise ValueError(\"Invalid byte_order: {}\".format(byte_order))\n        self.byte_order = byte_order\n\n    def map_name(self, proc: lldb.SBProcess, name: str) -> str:\n        return name\n\n    def map_value(self, proc: lldb.SBProcess, name: str, value: bytes) -> RegVal:\n        return RegVal(self.map_name(proc, name), value)\n\n    def map_name_back(self, proc: lldb.SBProcess, name: str) -> str:\n        return name\n\n    def map_value_back(self, proc: lldb.SBProcess, name: str,\n                       value: bytes) -> RegVal:\n        if self.byte_order == 'little':\n            value = bytes(reversed(value))\n        return RegVal(self.map_name_back(proc, name), value)\n\n","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/arch.py#L280-L316","documentation":"Raised by DefaultRegisterMapper.__init__ in the Ghidra LLDB agent when the byte_order argument is not one of 'big' or 'little'. The mapper needs a valid endianness to encode/decode register byte values; any other string (or a typo like 'BIG', 'LE', 'big-endian') is rejected at construction. ValueError signals an invalid configuration argument.","triggerScenarios":"Constructing DefaultRegisterMapper (or a subclass) with byte_order set from an unvalidated source — e.g. derived from LLDB's target byte order enum/string without normalization, a hardcoded value with a typo, or a config file value 'BE'/'LE'. Reached during compute_register_mapper / trace start.","commonSituations":"LLDB reports byte order in a form (e.g. 'little_endian', 'eByteOrderLittle') that was not normalized to 'little'; language config supplying abbreviated endianness; platform/target whose byte order string changed across LLDB versions.","solutions":["Normalize the source byte-order value to exactly 'big' or 'little' before constructing the mapper.","Add a translation step mapping LLDB's byte-order enum to {'big','little'}.","Validate config-supplied endianness against {'big','little'} with a clear error before passing it in.","Default to the target's detected endianness via a single normalized accessor."],"exampleFix":"// before\nmapper = DefaultRegisterMapper(raw_byte_order)\n// after\n_order = {'eByteOrderLittle': 'little', 'eByteOrderBig': 'big',\n          'little_endian': 'little', 'big_endian': 'big'}.get(raw_byte_order)\nif _order is None:\n    raise ValueError(f\"cannot normalize byte_order: {raw_byte_order}\")\nmapper = DefaultRegisterMapper(_order)","handlingStrategy":"validation","validationCode":"_NORMAL = {'little', 'big'}\n_order = raw_byte_order.lower() if isinstance(raw_byte_order, str) else None\nif _order not in _NORMAL:\n    raise ValueError(f\"cannot normalize byte_order: {raw_byte_order}\")\nmapper = arch.DefaultRegisterMapper(_order)","typeGuard":"def is_valid_byte_order(v) -> bool:\n    return isinstance(v, str) and v in {'big', 'little'}","tryCatchPattern":"try:\n    mapper = arch.DefaultRegisterMapper(byte_order)\nexcept ValueError:\n    # invalid endianness; fall back to detected endianness\n    mapper = arch.DefaultRegisterMapper(detected_endianness())","preventionTips":["normalize all byte-order inputs to 'big'/'little' at the boundary","map LLDB byte-order enums through a single accessor","validate config values before construction"],"tags":["ghidra","lldb","config","value-error","endianness","registers"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}