NationalSecurityAgency/ghidra · error · ValueError

max out of range of int64

Error message

max out of range of int64

What it means

Thrown by the Python ghidratrace Lifespan dataclass's __post_init__ when the `max` field exceeds LIFESPAN_MAX (2**63 - 1, the largest signed 64-bit value). Snap numbers are int64 on the wire, so the client rejects out-of-range values.

Source

Thrown at Ghidra/Debug/Debugger-rmi-trace/src/main/py/src/ghidratrace/client.py:118

    def length(self) -> int:
        return self.max - self.min + 1


LIFESPAN_MIN = -1 << 63
LIFESPAN_MAX = (1 << 63) - 1


@dataclass(frozen=True)
class Lifespan:
    min: int = LIFESPAN_MIN
    max: int = LIFESPAN_MAX

    def __post_init__(self) -> None:
        if self.min < LIFESPAN_MIN:
            raise ValueError("min out of range of int64")
        if self.max > LIFESPAN_MAX:
            raise ValueError("max out of range of int64")
        if self.min > self.max and not (self.min == 0 and self.max == -1):
            raise ValueError("min cannot exceed max")

    def is_empty(self) -> bool:
        return self.min == 0 and self.max == -1

    def __str__(self) -> str:
        if self.is_empty():
            return "(EMPTY)"
        min = '(-inf' if self.min == LIFESPAN_MIN else f'[{self.min}'
        max = '+inf)' if self.max == LIFESPAN_MAX else f'{self.max}]'
        return f'{min},{max}'

    def __repr__(self) -> str:
        return 'Lifespan' + self.__str__()


@dataclass

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Clamp max to LIFESPAN_MAX (module constant) before constructing the Lifespan.
  2. If you want an open-ended upper bound, pass LIFESPAN_MAX explicitly instead of a huge computed number.
  3. Re-check the snap arithmetic for overflow.

Example fix

# before
span = Lifespan(min=0, max=base_snap + huge_delta)

# after
from ghidratrace.client import LIFESPAN_MAX
hi = min(base_snap + huge_delta, LIFESPAN_MAX)
span = Lifespan(min=0, max=hi)
Defensive patterns

Strategy: validation

Validate before calling

from ghidratrace.client import LIFESPAN_MAX, Lifespan
hi = min(value, LIFESPAN_MAX)
span = Lifespan(min=LIFESPAN_MIN, max=hi)

Type guard

def valid_max(v: int) -> bool:
    from ghidratrace.client import LIFESPAN_MAX
    return v <= LIFESPAN_MAX

Try / catch

try:
    span = Lifespan(min=lo, max=hi)
except ValueError:
    hi = min(hi, LIFESPAN_MAX)
    span = Lifespan(min=lo, max=hi)

Prevention

When it happens

Trigger: Constructing Lifespan(max=...) with a value greater than 9223372036854775807, e.g. from arithmetic that overflows int64 or from an unbounded/very large value.

Common situations: Adding a large delta to a snap that overflows; passing sys.maxsize or a Python arbitrary-precision int that exceeds int64; using a far-future snap.

Related errors


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