NationalSecurityAgency/ghidra · critical · IllegalStateException

Could not determine where to create new frame

Error message

Could not determine where to create new frame

What it means

Thrown as IllegalStateException by DBTraceStack.doAddStackFrame when the schema search filter, after applying the level as an index key, yields no single canonical relative path. This means the trace's object schema does not define a placeable location for a TraceStackFrame at the given level — the schema is missing or misconfigured the stack-frame child relation.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/stack/DBTraceStack.java:104

	@Override
	public int getDepth(long snap) {
		try (LockHold hold = object.getTrace().lockRead()) {
			return object
					.querySuccessorsInterface(Lifespan.at(snap), TraceStackFrame.class, true)
					.map(f -> f.getLevel())
					.reduce(Integer::max)
					.map(m -> m + 1)
					.orElse(0);
		}
	}

	protected TraceStackFrame doAddStackFrame(long snap, int level) {
		try (LockHold hold = object.getTrace().lockWrite()) {
			PathFilter filter =
				object.getSchema().searchFor(TraceStackFrame.class, true);
			KeyPath relPath = filter.applyKeys(KeyPath.makeIndex(level)).getSingletonPath();
			if (relPath == null) {
				throw new IllegalStateException("Could not determine where to create new frame");
			}
			KeyPath path = object.getCanonicalPath().extend(relPath);
			return object.getManager().addStackFrame(path, snap);
		}
	}

	protected void copyFrameAttributes(long snap, TraceStackFrame from, TraceStackFrame to) {
		// Program Counter is the only attribute?
		to.setProgramCounter(Lifespan.nowOn(snap), from.getProgramCounter(snap));
	}

	protected void shiftFrameAttributes(long snap, int from, int to, int count,
			List<TraceStackFrame> frames) {
		if (from == to) {
			return;
		}
		if (from < to) {
			for (int i = count - 1; i >= 0; i--) {

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the trace's schema includes a TraceStackFrame relation reachable by searchFor(TraceStackFrame.class, true).
  2. Recreate the trace with the current framework schema if it was authored by an incompatible version.
  3. Report the schema configuration; this is generally not recoverable at runtime via addFrame.
Defensive patterns

Strategy: try-catch

Validate before calling

PathFilter f = stack.getSchema().searchFor(TraceStackFrame.class, true);
if (f.applyKeys(KeyPath.makeIndex(level)).getSingletonPath() == null) {
    // schema cannot place a frame here; abort or repair schema
}

Try / catch

try { stack.addFrame(level); }
catch (IllegalStateException e) {
    if (e.getMessage().contains("Could not determine")) { /* schema issue */ }
    else throw e;
}

Prevention

When it happens

Trigger: Calling stack.addFrame(level) on a trace whose schema was not configured to allow indexed TraceStackFrame children under the stack object. Corrupted or incomplete schema; a custom schema that omitted the frame element.

Common situations: Loading a trace created by an older/newer Ghidra version whose schema differs; using a target connector that emits no stack schema; programmatic schema manipulation.

Related errors


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