NationalSecurityAgency/ghidra · error · ValueError

Invalid byte_order: {}

Error message

Invalid byte_order: {}

What it means

Thrown by DefaultRegisterMapper.__init__() when the byte_order parameter is not one of the two accepted values 'big' or 'little'. The constructor validates byte_order against the allowed list and raises ValueError for any other input. This is a configuration-time error in the debugger agent's register mapper setup.

Source

Thrown at Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/arch.py:238

        raise ValueError(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):
        return name

    def map_value(self, proc: int, name: str, value: int):
        try:
            # TODO: this seems half-baked
            av = value.to_bytes(8, "big")
        except Exception:
            raise ValueError("Cannot convert {}'s value: '{}', type: '{}'"
                             .format(name, value, type(value)))
        return RegVal(self.map_name(proc, name), av)

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

    def map_value_back(self, proc: int, name: str, value: bytes):

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check the value being passed to DefaultRegisterMapper — ensure it's exactly 'big' or 'little'.
  2. Trace the byte_order source: usually derived from the language's endianness in compute_ghidra_language().
  3. If the architecture detection is wrong, fix the heuristic that determines endianness for the target.
  4. Add a fallback default (e.g., 'little' for x86) when detection is ambiguous.

Example fix

# Before:
# mapper = arch.DefaultRegisterMapper(computed_endian)  # computed_endian is None or ''
#
# After:
# endian = computed_endian if computed_endian in ('big', 'little') else 'little'
# mapper = arch.DefaultRegisterMapper(endian)
Defensive patterns

Strategy: validation

Validate before calling

# Before constructing the mapper, validate byte_order:
if byte_order not in ('big', 'little'):
    byte_order = 'little'  # or detect from language
mapper = arch.DefaultRegisterMapper(byte_order)

Type guard

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

Try / catch

try:
    mapper = arch.DefaultRegisterMapper(byte_order)
except ValueError as e:
    if 'Invalid byte_order' in str(e):
        # fall back to detected or default endianness
        mapper = arch.DefaultRegisterMapper('little')
    else:
        raise

Prevention

When it happens

Trigger: DefaultRegisterMapper(byte_order) is instantiated with a string that isn't 'big' or 'little'. The check `if not byte_order in ['big', 'little']` triggers. This happens when the architecture detection code passes an incorrect or empty byte_order string, or when a custom language configuration specifies an invalid endianness.

Common situations: The language detection code in arch.py fails to detect the correct endianness and passes None, an empty string, or a typo. A custom processor model reports an unrecognized endianness attribute. The byte_order is derived from a debugger query that returned an unexpected format.

Related errors


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