NationalSecurityAgency/ghidra · error · ValueError

Invalid byte_order: {}

Error message

Invalid byte_order: {}

What it means

Raised as ValueError by DefaultRegisterMapper.__init__() when byte_order is neither 'big' nor 'little'. It is a construction-time guard ensuring register byte serialization is well-defined.

Source

Thrown at Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/arch.py:187

            f"Address {address} is not in process {proc}")


DEFAULT_MEMORY_MAPPER = DefaultMemoryMapper('ram')

memory_mappers: Dict[str, DefaultMemoryMapper] = {}


def compute_memory_mapper(lang: str) -> DefaultMemoryMapper:
    if not lang in memory_mappers:
        return DEFAULT_MEMORY_MAPPER
    return memory_mappers[lang]


class DefaultRegisterMapper(object):

    def __init__(self, byte_order: str) -> None:
        if not byte_order in ['big', 'little']:
            raise ValueError("Invalid byte_order: {}".format(byte_order))
        self.byte_order = byte_order

    def map_name(self, proc: int, name: str) -> str:
        return name

    def map_value(self, proc: int, name: str, value: bytes):
        return RegVal(self.map_name(proc, name), value)

    def map_name_back(self, proc: int, name: str):
        return name

    def map_value_back(self, proc: int, name: str, value: bytes):
        return RegVal(self.map_name_back(proc, name), value)


DEFAULT_BE_REGISTER_MAPPER = DefaultRegisterMapper('big')
DEFAULT_LE_REGISTER_MAPPER = DefaultRegisterMapper('little')

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Normalize the byte_order argument to exactly 'big' or 'little' before constructing the mapper.
  2. Fix the language-id detection (compute_register_mapper) so it maps to a valid endianness.
  3. Guard the value with an assert or precondition before construction.

Example fix

// before
mapper = DefaultRegisterMapper('BE')  # raises
// after
bo = 'big' if endian in ('big','BE','big-endian') else 'little'
mapper = DefaultRegisterMapper(bo)
Defensive patterns

Strategy: validation

Validate before calling

if byte_order not in ('big', 'little'):
    raise ValueError(f'byte_order must be big/little, got {byte_order!r}')
mapper = arch.DefaultRegisterMapper(byte_order)

Type guard

def is_valid_byte_order(bo) -> bool:
    return bo in ('big', 'little')

Try / catch

try:
    mapper = arch.DefaultRegisterMapper(byte_order)
except ValueError as e:
    bo = 'big' if str(byte_order).upper().startswith('B') else 'little'
    mapper = arch.DefaultRegisterMapper(bo)

Prevention

When it happens

Trigger: Instantiating DefaultRegisterMapper (directly or via compute_register_mapper) with a byte_order string outside {'big','little'}.

Common situations: Passing an arch endianness token like 'BE'/'LE'/'big-endian' instead of the exact 'big'/'little' strings; misconfigured language id that yields an unexpected endianness.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/d6c51d5fc22e85ec. Report an issue: GitHub.