NationalSecurityAgency/ghidra · error · ValueError

Address {address} is not in inferior {inf.num}

Error message

Address {address} is not in inferior {inf.num}

What it means

Thrown as a ValueError by map_back in the gdb agent's DefaultMemoryMapper when the Address's space field does not match either the default space (for inferior #1) or the inferior-specific space (defaultSpace + inf.num). This reverse-mapping function translates a Ghidra Address back to a local offset; a space mismatch means the address belongs to a different inferior's address space.

Source

Thrown at Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/arch.py:235

class DefaultMemoryMapper(object):

    def __init__(self, defaultSpace: str) -> None:
        self.defaultSpace = defaultSpace

    def map(self, inf: gdb.Inferior, offset: int) -> Tuple[str, Address]:
        if inf.num == 1:
            space = self.defaultSpace
        else:
            space = f'{self.defaultSpace}{inf.num}'
        return self.defaultSpace, Address(space, offset)

    def map_back(self, inf: gdb.Inferior, address: Address) -> int:
        if address.space == self.defaultSpace and inf.num == 1:
            return address.offset
        if address.space == f'{self.defaultSpace}{inf.num}':
            return address.offset
        raise ValueError(f"Address {address} is not in inferior {inf.num}")


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(f"Invalid byte_order: {byte_order}")

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the Address object's space matches the current inferior's expected space (defaultSpace for inf 1, defaultSpace+infnum otherwise).
  2. Re-derive the address using map() for the correct inferior before calling map_back().
  3. Verify gdb.selected_inferior().num matches the inferior that produced the Address.
Defensive patterns

Strategy: validation

Validate before calling

def validate_address_for_inferior(address: Address, inf: gdb.Inferior, default_space: str) -> bool:
    expected = default_space if inf.num == 1 else f'{default_space}{inf.num}'
    return address.space == expected

Try / catch

try:
    offset = mapper.map_back(inf, address)
except ValueError as e:
    if 'is not in inferior' in str(e):
        print(f'Address space mismatch: {address.space} vs inferior {inf.num}')
    raise

Prevention

When it happens

Trigger: Calling map_back with an Address whose space is 'ram3' while the current inferior is #2 (expected 'ram2'), or an Address with space 'ram2' while the current inferior is #1 (expected 'ram'). The check is strict: only the exact space for the given inferior number is accepted.

Common situations: Cross-inferior address references in multi-process GDB debugging; stale address objects cached from a previous inferior selection; address space naming mismatch after an inferior is added or removed.

Related errors


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