{"record":{"id":"bea129dbd9715889","repo":"NationalSecurityAgency/ghidra","slug":"cannot-convert-address-to-address","errorCode":null,"errorMessage":"Cannot convert '{address}' to address","messagePattern":"Cannot convert '(.+?)' to address","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py","lineNumber":549,"sourceCode":"            if isinstance(count, Future):\n                count.add_done_callback(lambda c: print(f\"Wrote {c} bytes\"))\n            else:\n                print(f\"Wrote {count} bytes\")\n        if isinstance(count, Future):\n            return {'count': -1}\n        else:\n            return {'count': count}\n    return {'count': 0}\n\n\ndef eval_address(address: Union[str, int]) -> int:\n    try:\n        result = util.parse_and_eval(address)\n        if isinstance(result, int):\n            return result\n        raise ValueError(f\"Value '{address}' does not evaluate to an int\")\n    except Exception:\n        raise RuntimeError(f\"Cannot convert '{address}' to address\")\n\n\ndef eval_range(address: Union[str, int],\n               length: Union[str, int]) -> Tuple[int, int]:\n    start = eval_address(address)\n    try:\n        l = util.parse_and_eval(length)\n    except Exception as e:\n        raise RuntimeError(f\"Cannot convert '{length}' to length\")\n    if not isinstance(l, int):\n        raise ValueError(f\"Value '{address}' does not evaluate to an int\")\n    end = start + l\n    return start, end\n\n\ndef putmem(address: Union[str, int], length: Union[str, int],\n           pages: bool = True, display_result: bool = True) -> Dict[str, int]:\n    start, end = eval_range(address, length)","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-dbgeng/src/main/py/src/ghidradbg/commands.py#L531-L567","documentation":"Raised by eval_address() (commands.py:542-549) when util.parse_and_eval(address) either throws or returns a non-int. eval_address is the central resolver that turns a user-supplied string or int (a symbol, expression, or hex literal) into a numeric address via the dbgeng expression evaluator. Any failure is normalized to this RuntimeError, masking the underlying cause.","triggerScenarios":"Calling ghidra_trace_putmem/ghidra_trace_delmem/ghidra_trace_putmem_state with a symbol that does not exist in the current module; passing an expression referencing an unloaded module; passing a malformed hex like '0xZZ'; passing a value when no process is loaded so the evaluator has no symbol context.","commonSituations":"Symbol not yet resolved because the target DLL/module is not loaded at the time of the call; typo in a symbol name; wrong radix ('#' MASM suffix in a C++ evaluator, or vice versa); calling before the process is in a break state.","solutions":["Confirm the symbol exists at the current break with the debugger's native evaluator (e.g. '? mysymbol' or 'x mymodule!sym') before issuing the command.","Verify a process is loaded and the debugger is in break state so the evaluator has context.","Pass a plain hex int (0x...) to bypass symbol resolution when you know the address.","Check the evaluator syntax matches the current mode (MASM vs C++)."],"exampleFix":"// before\nghidra_trace_putmem('mymissingmod!main', 0x100)\n\n// after\n# resolve/verify first:\n# WinDbg> x mymodule!main\nghidra_trace_putmem('mymodule!main', 0x100)\n# or pass a known address directly:\nghidra_trace_putmem(0x140001000, 0x100)","handlingStrategy":"try-catch","validationCode":"def resolve_address_safe(expr):\n    try:\n        v = util.parse_and_eval(expr)\n    except Exception:\n        return None\n    return v if isinstance(v, int) else None\n\naddr = resolve_address_safe(address)\nif addr is None:\n    raise ValueError(f'cannot resolve address {address!r}; check symbol/mode')","typeGuard":"def address_resolves(expr) -> bool:\n    try:\n        return isinstance(util.parse_and_eval(expr), int)\n    except Exception:\n        return False","tryCatchPattern":"try:\n    ghidra_trace_putmem(address, length)\nexcept RuntimeError as e:\n    if 'Cannot convert' in str(e) and 'to address' in str(e):\n        # fall back to a literal int address, or verify symbol first\n        raise ValueError(f'unresolvable address: {address!r}') from e\n    raise","preventionTips":["Verify symbols with 'x module!sym' before referencing them.","Pass literal hex ints when you know the address.","Ensure the target is in break state with modules loaded."],"tags":["expression-eval","symbols","memory","ghidra"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}