{"record":{"id":"977244cee74b565e","repo":"NationalSecurityAgency/ghidra","slug":"cannot-convert-address-to-address-e","errorCode":null,"errorMessage":"Cannot convert '{address}' to address: {e}","messagePattern":"Cannot convert '(.+?)' to address: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py","lineNumber":683,"sourceCode":"        elif isinstance(count, Future):\n            if count.done():\n                result.PutCString(f\"Wrote {count.result()} bytes\")\n            else:\n                count.add_done_callback(lambda c: check_count(c.result(), len(buf)))\n                result.PutCString(\n                    f\"Wrong {len(buf)} bytes, perhaps in the future\")\n        else:\n            result.PutCString(f\"Wrote {count} bytes\")\n    else:\n        raise RuntimeError(f\"Cannot read memory at {start:x}\")\n\n\ndef eval_address(address: str) -> Optional[int]:\n    try:\n        return util.parse_and_eval(address)\n    except BaseException as e:\n        if \"can't evaluate expressions when the process is running\" not in str(e):\n            raise RuntimeError(f\"Cannot convert '{address}' to address: {e}\")\n        return None\n\n\ndef eval_range(address: str, length: str) -> Tuple[Optional[int], Optional[int]]:\n    start = eval_address(address)\n    if start is None:\n        return None, None\n    try:\n        end = start + util.parse_and_eval(length)\n    except BaseException as e:\n        raise RuntimeError(f\"Cannot convert '{length}' to length: {e}\")\n    return start, end\n\n\ndef putmem(address: str, length: str, result: lldb.SBCommandReturnObject,\n           pages: bool = True) -> None:\n    start, end = eval_range(address, length)\n    if start is not None and end is not None:","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py#L665-L701","documentation":"Raised in `eval_address` when `util.parse_and_eval(address)` throws any exception other than the 'can't evaluate expressions when the process is running' message. The original exception text is embedded, so the address expression could not be evaluated to a numeric value in the current target.","triggerScenarios":"`ghidra trace putmem foo 0x10` where `foo` is not a symbol LLDB can resolve; an expression syntax error; no target loaded; a symbol that is out of scope in the current frame.","commonSituations":"A typo in a symbol name; evaluating an expression with no symbol context loaded; using GDB-style syntax LLDB rejects; referencing a variable not present in the selected frame.","solutions":["Verify the expression in LLDB first: `p/x <expr>` or `expression <expr>`","Use a concrete hex address if the symbol is ambiguous or not yet loaded","Ensure a target is loaded and (for symbols) the correct frame/scope is selected","Rewrite the expression in LLDB syntax rather than GDB syntax"],"exampleFix":"// before\nghidra trace putmem foo 0x10\n// after\n(lldb) p/x &myvar        # obtain the address\nghidra trace putmem 0x<addr> 0x10","handlingStrategy":"validation","validationCode":"import lldb\n\ndef expr_resolves(expr: str) -> bool:\n    # mirror what eval_address relies on (util.parse_and_eval)\n    val = lldb.debugger.GetTargetAtIndex(0).EvaluateExpression(expr)\n    return val.IsValid() and val.GetError().Success()","typeGuard":"import lldb\n\ndef resolves_to_address(expr: str) -> int | None:\n    val = lldb.debugger.GetTargetAtIndex(0).EvaluateExpression(expr)\n    if val.IsValid() and val.GetError().Success() and val.GetType().IsPointerType():\n        return val.GetValueAsUnsigned()\n    return None","tryCatchPattern":"try:\n    start = eval_address(address)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Cannot convert '\"):\n        # the expression did not resolve; fix the symbol/syntax or use a concrete address\n        ...\n    raise","preventionTips":["Test the expression in LLDB with `p/x <expr>` before passing it","Fall back to a concrete hex address when a symbol is ambiguous or unloaded","Use LLDB expression syntax, not GDB syntax","Ensure the target is loaded and the right frame is selected for symbol resolution"],"tags":["memory","ghidra","lldb","expression-evaluation","put"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}