NationalSecurityAgency/ghidra · error · RuntimeError

Not connected

Error message

Not connected

What it means

Raised by State.require_client in the Ghidra LLDB agent when STATE.client is None — i.e. no connection to the Ghidra trace-rpc server has been established. Commands that need to send trace data to Ghidra (create_trace, putmem, etc.) call require_client; without a Client the operation cannot proceed. RuntimeError signals a lifecycle precondition: 'connect' must precede any client-using command.

Source

Thrown at Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py:98

    def require_mm(self) -> arch.DefaultMemoryMapper:
        if self.memory_mapper is None:
            raise RuntimeError("No memory mapper")
        return self.memory_mapper

    def require_rm(self) -> arch.DefaultRegisterMapper:
        if self.register_mapper is None:
            raise RuntimeError("No register mapper")
        return self.register_mapper


class State(object):

    def __init__(self) -> None:
        self.reset_client()

    def require_client(self) -> Client:
        if self.client is None:
            raise RuntimeError("Not connected")
        return self.client

    def require_no_client(self) -> None:
        if self.client is not None:
            raise RuntimeError("Already connected")

    def reset_client(self) -> None:
        self.client: Optional[Client] = None
        self.reset_trace()

    def require_trace(self) -> Trace[Extra]:
        if self.trace is None:
            raise RuntimeError("No trace active")
        return self.trace

    def require_no_trace(self) -> None:
        if self.trace is not None:
            raise RuntimeError("Trace already started")

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the connect command first (ghidra_trace_connect host:port) before any trace-emitting command.
  2. In scripts, guard with a connection check (STATE.client is not None) before issuing commands.
  3. Catch RuntimeError in command wrappers and print a 'not connected; run ghidra_trace_connect' hint.
  4. Verify the host:port and that the Ghidra script (TraceConnectLaunchTraceServerScript) is running.

Example fix

// before
client = STATE.require_client()
// after
if STATE.client is None:
    print("Not connected. Run: ghidra_trace_connect <host:port>")
    return
client = STATE.require_client()
Defensive patterns

Strategy: validation

Validate before calling

if STATE.client is None:
    print("Not connected. Run: ghidra_trace_connect <host:port>")
    return
client = STATE.require_client()

Type guard

def is_connected() -> bool:
    return STATE.client is not None

Try / catch

try:
    client = STATE.require_client()
except RuntimeError:
    print("Not connected; run ghidra_trace_connect first")
    return

Prevention

When it happens

Trigger: Running a trace/command that calls STATE.require_client() before the agent connected to Ghidra (e.g. 'ghidra_trace' commands issued before 'ghidra_trace_connect' <host:port>). Reached by ~the majority of commands.py that touch the server.

Common situations: User issued trace commands out of order (forgot 'connect'); connection dropped and client was reset (reset_client) but user continued issuing commands; script that begins tracing without first connecting.

Related errors


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