NationalSecurityAgency/ghidra · error · IllegalStateException

There is no thread

Error message

There is no thread

What it means

Thrown by FlatDebuggerAPI.requireThread(thread) when the caller passes a null thread reference. This is a null-check guard for an explicitly supplied thread argument.

Source

Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java:274

	 */
	default TraceThread requireCurrentThread() {
		TraceThread thread = getCurrentThread();
		if (thread == null) {
			throw new IllegalStateException("There is no current thread");
		}
		return thread;
	}

	/**
	 * Require that the given thread is not null
	 * 
	 * @param thread the thread
	 * @return the thread
	 * @throws IllegalStateException if the thread is null
	 */
	default TraceThread requireThread(TraceThread thread) {
		if (thread == null) {
			throw new IllegalStateException("There is no thread");
		}
		return thread;
	}

	/**
	 * Get the current trace program view
	 * 
	 * <p>
	 * The view is an adapter for traces that allows them to be used as a {@link Program}. However,
	 * it only works for a chosen snapshot. Typically, {@link TraceProgramView#getSnap()} for this
	 * view will give the same result as {@link #getCurrentSnap()}. The exception is when the UI is
	 * displaying emulated (scratch) machine state. In that case, {@link #getCurrentSnap()} will
	 * give the "source" snapshot of the emulated state, and {@link TraceProgramView#getSnap()} will
	 * give the "destination" scratch snapshot. See {@link #getCurrentEmulationSchedule()}.
	 * 
	 * @see #getCurrentDebuggerCoordinates()
	 * @return the view
	 */

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check the thread variable for null before calling requireThread().
  2. Validate the lookup index/id against the trace's thread list before indexing.
  3. Use getCurrentThread() if you meant the active thread.

Example fix

// before
TraceThread th = trace.getThreadManager().getThread(idx); // may be null
requireThread(th); // throws

// after
TraceThread th = trace.getThreadManager().getThread(idx);
if (th == null) {
    println("No thread at index " + idx);
    return;
}
Defensive patterns

Strategy: validation

Validate before calling

if (thread == null) {
    println("Thread reference is null");
    return;
}

Type guard

static boolean isNonNullThread(TraceThread t) {
    return t != null;
}

Try / catch

try {
    requireThread(thread);
} catch (IllegalStateException e) {
    if (e.getMessage().equals("There is no thread")) {
        thread = getCurrentThread();
    } else throw e;
}

Prevention

When it happens

Trigger: Calling requireThread(someThread) where someThread is null, e.g., a thread obtained from a lookup by index that did not exist.

Common situations: Looking up a thread by index/id that is out of range; passing a thread reference from a stale trace; chaining lookups with a null intermediate result.

Related errors


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