{"record":{"id":"b8f08b32a162288c","repo":"NationalSecurityAgency/ghidra","slug":"value-address-does-not-evaluate-to-an-int-b8f08b","errorCode":null,"errorMessage":"Value '{address}' does not evaluate to an int","messagePattern":"Value '(.+?)' does not evaluate to an int","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py","lineNumber":461,"sourceCode":"        count = trace.put_bytes(addr, buf)\n        if display_result:\n            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],","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py#L443-L479","documentation":"Raised as a ValueError inside eval_address (commands.py:458-461) when util.parse_and_eval(address) returns successfully but the result is not an int. This ValueError is immediately caught by the enclosing 'except Exception' (line 462) and re-raised as the RuntimeError 'Cannot convert ... to address', so a caller normally never observes this exact message directly; it surfaces only if the inner ValueError propagates in a context without the wrapper.","triggerScenarios":"util.parse_and_eval returns a non-int (e.g. a register name resolving to a bytes/string object, an expression that evaluates to a float or a string). The condition 'isinstance(result, int)' is False, so the ValueError is raised and then converted.","commonSituations":"Passing a symbol/expression that the evaluator resolves to a non-numeric type; a debugger state where parse_and_eval yields a string representation rather than a raw int; version differences in what parse_and_eval returns.","solutions":["Pass an address that evaluates to an integer (a hex literal, a symbol that resolves to an int, or an int directly).","Coerce the result yourself before calling eval_address: int(util.parse_and_eval(x)).","Treat the user-visible symptom as error [287] ('Cannot convert ... to address') and fix the input expression."],"exampleFix":"// before\neval_address('some_string_symbol')  # resolves to non-int\n\n// after\neval_address(0x00400000)  # pass an int directly","handlingStrategy":"type-guard","validationCode":"def eval_address_safe(address):\n    result = util.parse_and_eval(address)\n    if not isinstance(result, int):\n        raise TypeError(f'{address!r} evaluated to {type(result).__name__}, not int')\n    return result","typeGuard":"def evaluates_to_int(address) -> bool:\n    try:\n        return isinstance(util.parse_and_eval(address), int)\n    except Exception:\n        return False","tryCatchPattern":"try:\n    addr = eval_address(address)\nexcept RuntimeError:\n    addr = int(address, 16) if isinstance(address, str) else int(address)","preventionTips":["Prefer passing integer literals for addresses when symbols are uncertain.","Test parse_and_eval return type before relying on it.","Remember this inner ValueError is normally converted to error [287]; fix the input expression."],"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"}