{"record":{"id":"3830ec265dc34426","repo":"NationalSecurityAgency/ghidra","slug":"cannot-convert-address-to-address-3830ec","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-x64dbg/src/main/py/src/ghidraxdbg/commands.py","lineNumber":463,"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":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py#L445-L481","documentation":"Raised by eval_address (commands.py:462-463) as the user-facing RuntimeError wrapping every failure inside the try block: parse_and_eval throwing, returning a non-int (the inner ValueError from [286]), or any other Exception. It is the catch-all 'address could not be converted' message that callers actually see.","triggerScenarios":"Calling eval_address (directly or via putmem/delmem/putmem_state/ghidra_trace_putmem etc.) with an address expression that parse_and_eval cannot resolve to an integer: an undefined symbol, malformed expression, or a value of the wrong type.","commonSituations":"Typos in symbol names; querying an address before the module/symbols are loaded; passing an expression syntax the evaluator does not understand; a debugger not in a state where evaluation is possible.","solutions":["Verify the address expression resolves before using it: test util.parse_and_eval(address) interactively.","Pass a literal hex/integer address when symbols are unavailable.","Ensure the target process/module is loaded so symbol resolution succeeds.","Catch RuntimeError around eval_address and report the bad input to the user."],"exampleFix":"// before\nputmem('UndefinedSymbol', 0x10)  # -> Cannot convert 'UndefinedSymbol' to address\n\n// after\nputmem('main', 0x10)  # resolved symbol, or\nputmem(0x00401000, 0x10)  # literal address","handlingStrategy":"try-catch","validationCode":"def try_eval_address(address):\n    try:\n        r = util.parse_and_eval(address)\n    except Exception:\n        return int(address, 16) if isinstance(address, str) else int(address)\n    return r if isinstance(r, int) else int(address, 0)","typeGuard":"def is_evaluatable_address(address) -> bool:\n    try:\n        return isinstance(util.parse_and_eval(address), int)\n    except Exception:\n        return isinstance(address, int) or (\n            isinstance(address, str) and address.strip().startswith(('0x', '0X'))\n        )","tryCatchPattern":"try:\n    putmem(address, length)\nexcept RuntimeError as e:\n    if 'Cannot convert' in str(e) and 'to address' in str(e):\n        log.warning('bad address %r; skipping', address)\n    else:\n        raise","preventionTips":["Verify symbol resolution interactively before scripting putmem/delmem.","Fall back to literal hex addresses when symbols are unavailable.","Ensure the target process/module is loaded so evaluation has context."],"tags":["evaluation","address-parsing","trace-agent","python"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}