{"record":{"id":"cc9a1d8659ae0713","repo":"NationalSecurityAgency/ghidra","slug":"no-memory-mapper","errorCode":null,"errorMessage":"No memory mapper","messagePattern":"No memory mapper","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py","lineNumber":105,"sourceCode":"\n\nclass ErrorWithCode(Exception):\n\n    def __init__(self, code: int) -> None:\n        self.code = code\n\n    def __str__(self) -> str:\n        return repr(self.code)\n\n\nclass Extra(object):\n    def __init__(self) -> None:\n        self.memory_mapper: Optional[arch.DefaultMemoryMapper] = None\n        self.register_mapper: Optional[arch.DefaultRegisterMapper] = None\n\n    def require_mm(self) -> arch.DefaultMemoryMapper:\n        if self.memory_mapper is None:\n            raise RuntimeError(\"No memory mapper\")\n        return self.memory_mapper\n\n    def require_rm(self) -> arch.DefaultRegisterMapper:\n        if self.register_mapper is None:\n            raise RuntimeError(\"No register mapper\")\n        return self.register_mapper\n\n\nclass State(object):\n\n    def __init__(self) -> None:\n        self.reset_client()\n\n    def require_client(self) -> Client:\n        if self.client is None:\n            raise RuntimeError(\"Not connected\")\n        return self.client\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py#L87-L123","documentation":"Thrown by Extra.require_mm() when the memory_mapper attribute is None — meaning no architecture-specific memory mapper has been configured for the current debugging session. The debugger agent requires a memory mapper to translate between debugger offsets and Ghidra address spaces, and commands that need memory translation will fail until one is set.","triggerScenarios":"STATE.require_mm() (via Extra.require_mm()) is called by any command that needs to map memory addresses, but Extra.memory_mapper is still None from __init__. This happens when a memory-related command is issued before the architecture has been detected and the mapper initialized, or when arch detection fails silently.","commonSituations":"The user issues a memory read/write command before connecting and configuring the target architecture. The architecture detection (compute_ghidra_language) failed, so compute_memory_mapper returned the default but it was never assigned. The dbgeng session was reset without re-initializing the mapper.","solutions":["Ensure the target process is connected and architecture detection has run before issuing memory commands.","Call the architecture setup command that initializes both memory_mapper and register_mapper.","Check that compute_ghidra_language() succeeds and a valid mapper is assigned to STATE.extra.memory_mapper.","Reset and re-establish the debugging session if the mapper was lost."],"exampleFix":"# Before: issuing memory command without mapper\n# ghidra_trace_putmem(...)\n#\n# After: ensure mapper is initialized\n# if STATE.extra.memory_mapper is None:\n#     # run arch detection / connection setup first\n#     establish_arch()\n# ghidra_trace_putmem(...)","handlingStrategy":"validation","validationCode":"# Before calling require_mm, check and initialize if needed:\nif STATE.extra.memory_mapper is None:\n    # run architecture detection to set up mapper\n    arch.compute_memory_mapper(arch.compute_ghidra_language())\nSTATE.extra.require_mm()","typeGuard":"def has_memory_mapper(extra) -> bool:\n    return extra.memory_mapper is not None","tryCatchPattern":"try:\n    mm = STATE.extra.require_mm()\nexcept RuntimeError as e:\n    if str(e) == 'No memory mapper':\n        # run setup/arch detection, then retry\n        pass\n    else:\n        raise","preventionTips":["Always run architecture detection after connecting to set up both mappers.","Check mapper availability before issuing memory-related commands.","Re-initialize mappers after session resets (reset_client/reset_trace).","Follow the correct command lifecycle: connect > setup arch > start trace > commands."],"tags":["debugger-agent","memory-mapper","initialization","python","state-management"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}