NationalSecurityAgency/ghidra · error · ValueError

Value '{address}' does not evaluate to an int

Error message

Value '{address}' does not evaluate to an int

What it means

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.

Source

Thrown at Ghidra/Debug/Debugger-agent-x64dbg/src/main/py/src/ghidraxdbg/commands.py:461

        count = trace.put_bytes(addr, buf)
        if display_result:
            if isinstance(count, Future):
                count.add_done_callback(lambda c: print(f"Wrote {c} bytes"))
            else:
                print(f"Wrote {count} bytes")
        if isinstance(count, Future):
            return {'count': -1}
        else:
            return {'count': count}
    return {'count': 0}


def eval_address(address: Union[str, int]) -> int:
    try:
        result = util.parse_and_eval(address)
        if isinstance(result, int):
            return result
        raise ValueError(f"Value '{address}' does not evaluate to an int")
    except Exception:
        raise RuntimeError(f"Cannot convert '{address}' to address")


def eval_range(address: Union[str, int],
               length: Union[str, int]) -> Tuple[int, int]:
    start = eval_address(address)
    try:
        l = util.parse_and_eval(length)
    except Exception as e:
        raise RuntimeError(f"Cannot convert '{length}' to length")
    if not isinstance(l, int):
        raise ValueError(f"Value '{address}' does not evaluate to an int")
    end = start + l
    return start, end


def putmem(address: Union[str, int], length: Union[str, int],

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Pass an address that evaluates to an integer (a hex literal, a symbol that resolves to an int, or an int directly).
  2. Coerce the result yourself before calling eval_address: int(util.parse_and_eval(x)).
  3. Treat the user-visible symptom as error [287] ('Cannot convert ... to address') and fix the input expression.

Example fix

// before
eval_address('some_string_symbol')  # resolves to non-int

// after
eval_address(0x00400000)  # pass an int directly
Defensive patterns

Strategy: type-guard

Validate before calling

def eval_address_safe(address):
    result = util.parse_and_eval(address)
    if not isinstance(result, int):
        raise TypeError(f'{address!r} evaluated to {type(result).__name__}, not int')
    return result

Type guard

def evaluates_to_int(address) -> bool:
    try:
        return isinstance(util.parse_and_eval(address), int)
    except Exception:
        return False

Try / catch

try:
    addr = eval_address(address)
except RuntimeError:
    addr = int(address, 16) if isinstance(address, str) else int(address)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/b8f08b32a162288c. Report an issue: GitHub.