NationalSecurityAgency/ghidra · error · IllegalArgumentException

Given namespace is not in this trace

Error message

Given namespace is not in this trace

What it means

Thrown by DBTraceSymbolManager.assertIsMine(Namespace): the helper checkIsMine(ns) returned null, meaning the namespace is either not a DBTraceNamespaceSymbol or does not belong to this trace. The guard prevents operations on namespaces sourced from a different trace or from the Program namespace API.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/symbol/DBTraceSymbolManager.java:475

			return null;
		}
		long symbolID = dbSym.getID();
		byte tid = unpackTypeID(symbolID);
		AbstractDBTraceSymbolSingleTypeView<?> view = symbolViews.get(tid);
		if (view == null) {
			return null;
		}
		if (!view.store.containsKey(unpackKey(symbolID))) {
			return null;
		}
		return dbSym;
	}

	@Internal
	public DBTraceNamespaceSymbol assertIsMine(Namespace ns) {
		DBTraceNamespaceSymbol dbns = checkIsMine(ns);
		if (dbns == null) {
			throw new IllegalArgumentException("Given namespace is not in this trace");
		}
		return dbns;
	}

	@Internal
	public AbstractDBTraceSymbol assertIsMine(Symbol symbol) {
		AbstractDBTraceSymbol dbSym = checkIsMine(symbol);
		if (dbSym == null) {
			throw new IllegalArgumentException("Given symbol is not in this trace");
		}
		return dbSym;
	}

	protected static void assertValidName(String name) throws InvalidInputException {
		if (name == null || name.length() == 0 || !name.matches("\\p{Graph}+")) {
			throw new InvalidInputException(name);
		}
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Resolve or create the namespace within the target trace via trace.getSymbolManager().getOrCreateNamespace(...) before using it.
  2. Map foreign namespace names to namespaces owned by this trace.
  3. Guard with instanceof DBTraceNamespaceSymbol and trace ownership before calling assertIsMine-dependent APIs.
  4. Avoid caching Namespace handles across trace lifetimes.

Example fix

// before
symMgr.createLabel(span, addr, name, foreignNs, SourceType.USER, null);

// after
Namespace myNs = symMgr.getOrCreateNamespace(trace.getSymbolManager().getGlobalNamespace(), foreignNs.getName());
symMgr.createLabel(span, addr, name, myNs, SourceType.USER, null);
Defensive patterns

Strategy: validation

Validate before calling

Namespace myNs = (ns instanceof DBTraceNamespaceSymbol dbns
        && dbns.getTrace() == thisTrace)
    ? ns
    : symMgr.getOrCreateNamespace(symMgr.getGlobalNamespace(), ns != null ? ns.getName() : "");

Type guard

static boolean isMineNs(Trace trace, Namespace ns) {
    return ns instanceof DBTraceNamespaceSymbol dbns && dbns.getTrace() == trace;
}

Prevention

When it happens

Trigger: Passing a Namespace obtained from another Trace, from a Program (e.g. listing.getFunction(name).getParentNamespace()), or a mock/stub namespace into a trace symbol operation that calls assertIsMine(Namespace).

Common situations: Cross-trace copying of symbols; reusing a cached Namespace after the trace was closed; test code with mocked namespaces; mixing Program global namespace into trace symbol creation.

Related errors


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