NationalSecurityAgency/ghidra · error · RuntimeException

Trace already started

Error message

Trace already started

What it means

RuntimeException('Trace already started') thrown by State.requireNoTrace() when trace is already non-null. It guards start-trace commands that require no existing trace. Unlike requireNoClient, it does not clear the field before throwing.

Source

Thrown at Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java:91

			throw new RuntimeException("Already connected");
		}
	}

	public void resetClient() {
		client = null;
		resetTrace();
	}

	public RmiTrace requireTrace() {
		if (trace == null) {
			throw new RuntimeException("No trace started");
		}
		return trace;
	}

	public void requireNoTrace() {
		if (trace != null) {
			throw new RuntimeException("Trace already started");
		}
	}

	public void resetTrace() {
		trace = null;
		resetTx();
	}

	public RmiTransaction requireTx() {
		if (tx == null) {
			throw new RuntimeException("No transaction");
		}
		return tx;
	}

	public void requireNoTx() {
		if (tx != null) {
			throw new RuntimeException("Transaction already started");

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Reset the existing trace (resetTrace or the end-trace command) before starting a new one.
  2. Check state.trace == null before starting; if non-null, reuse the existing trace.
  3. Structure command sequences so start-trace is issued exactly once per session.

Example fix

// before
// start-trace issued again -> 'Trace already started'

// after
if (state.trace != null) {
    state.resetTrace();
}
startTrace(...);
Defensive patterns

Strategy: validation

Validate before calling

if (state.trace != null) {
    state.resetTrace();
}
startTrace(...);

Try / catch

try {
    state.requireNoTrace();
} catch (RuntimeException e) {
    if ("Trace already started".equals(e.getMessage())) {
        // reset trace, then start a new one
    }
}

Prevention

When it happens

Trigger: Calling the start-trace command (or any command routing through requireNoTrace()) while State.trace is already set from a previous start that was not reset.

Common situations: Running start-trace twice; reconnecting/restarting a session without first resetting the trace; a script that re-enters its setup block.

Related errors


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