NationalSecurityAgency/ghidra · error · ValueError

min out of range of int64

Error message

min out of range of int64

What it means

Thrown by the Python ghidratrace Lifespan dataclass's __post_init__ when the `min` field is below LIFESPAN_MIN (-2**63, the smallest signed 64-bit value). Lifespan snap numbers are transmitted to the Java side as int64, so the client validates bounds before sending.

Source

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

    def extend(cls, min: Address, length: int) -> 'AddressRange':
        return cls(min.space, min.offset, min.offset + length - 1)

    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__()

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Clamp min to LIFESPAN_MIN (use the module constant) before constructing the Lifespan.
  2. Re-check the arithmetic producing the snap number; treat snap 0 as the floor for live traces.
  3. If you need the open-ended lower bound, pass LIFESPAN_MIN explicitly rather than computing it.

Example fix

# before
span = Lifespan(min=base_snap - huge_delta)

# after
from ghidratrace.client import LIFESPAN_MIN
lo = max(base_snap - huge_delta, LIFESPAN_MIN)
span = Lifespan(min=lo, max=base_snap)
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

def valid_min(v: int) -> bool:
    from ghidratrace.client import LIFESPAN_MIN
    return v >= LIFESPAN_MIN

Try / catch

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

Prevention

When it happens

Trigger: Constructing Lifespan(min=...) with a value less than -9223372036854775808, e.g. from arithmetic that underflows or from an incorrectly computed offset.

Common situations: Subtracting a large snap delta from 0/snap 0 producing a value below int64 min; parsing a malformed schedule; passing a raw negative value by mistake.

Related errors


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