NationalSecurityAgency/ghidra · error · IllegalArgumentException

Platform is not part of this trace

Error message

Platform is not part of this trace

What it means

Thrown by DBTraceDefinedDataView.create() when the provided TracePlatform does not belong to this trace (platform.getTrace() != getTrace()) or is not an InternalTracePlatform instance. Data units must be created using a platform that is registered with the same trace object, because the data unit records store a platform key that is trace-local. Passing a foreign platform or an incompatible platform implementation is a precondition violation.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceDefinedDataView.java:76

	 * @return true if it is a function definition, false otherwise
	 */
	protected boolean isFunctionDefinition(DataType dt) {
		if (dt instanceof FunctionDefinition) {
			return true;
		}
		if (dt instanceof TypeDef) {
			TypeDef typeDef = (TypeDef) dt;
			return isFunctionDefinition(typeDef.getBaseDataType());
		}
		return false;
	}

	@Override
	public DBTraceDataAdapter create(Lifespan lifespan, Address address, TracePlatform platform,
			DataType origType, int origLength) throws CodeUnitInsertionException {
		if (platform.getTrace() != getTrace() ||
			!(platform instanceof InternalTracePlatform iPlatform)) {
			throw new IllegalArgumentException("Platform is not part of this trace");
		}
		try (LockHold hold = LockHold.lock(space.lock.writeLock())) {
			DBTraceMemorySpace memSpace = space.trace.getMemoryManager().get(space.space, true);
			// NOTE: User-given length could be ignored....
			// Check start address first. After I know length, I can check for other existing units
			long startSnap = lifespan.lmin();
			if (!space.undefinedData.coversRange(Lifespan.at(startSnap),
				new AddressRangeImpl(address, address))) {
				// TODO: Figure out the conflicting unit?
				throw new CodeUnitInsertionException("Code units cannot overlap");
			}

			DataType dataType;
			int length;
			if (origType instanceof FactoryDataType) {
				MemBuffer buffer = memSpace.getBufferAt(startSnap, address);
				FactoryDataType fdt = (FactoryDataType) origType;
				dataType = fdt.getDataType(buffer);

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Use the platform from the same trace: trace.getPlatformManager().getHostPlatform() or the correct guest platform from the same trace.
  2. Ensure any custom platform extends/implements InternalTracePlatform and is registered with the trace.
  3. Verify platform.getTrace() == trace before calling create().

Example fix

// before — platform from a different trace
DBTraceDefinedDataView view = otherTrace.getCodeManager().get(space, true).definedData();
view.create(lifespan, address, foreignPlatform, dataType); // throws

// after — use the platform from the owning trace
DBTraceDefinedDataView view = trace.getCodeManager().get(space, true).definedData();
TracePlatform platform = trace.getPlatformManager().getHostPlatform();
view.create(lifespan, address, platform, dataType);
Defensive patterns

Strategy: validation

Validate before calling

// Verify platform ownership before creating data units
if (platform.getTrace() != trace) {
    throw new IllegalArgumentException("Platform does not belong to this trace");
}
if (!(platform instanceof InternalTracePlatform)) {
    throw new IllegalArgumentException("Platform must be an InternalTracePlatform");
}
view.create(lifespan, address, platform, dataType);

Type guard

static boolean isTraceNativePlatform(TracePlatform platform, DBTrace trace) {
    return platform.getTrace() == trace && platform instanceof InternalTracePlatform;
}

Try / catch

try {
    view.create(lifespan, address, platform, dataType);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("not part of this trace")) {
        // Use the correct platform from the owning trace
        TracePlatform correctPlatform = trace.getPlatformManager().getHostPlatform();
        view.create(lifespan, address, correctPlatform, dataType);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling view.create(lifespan, address, platform, dataType) with a platform obtained from a different trace, or a custom TracePlatform implementation that is not an InternalTracePlatform. The instanceof + getTrace() check ensures only trace-native platforms are used.

Common situations: Using a platform from a different trace session; mixing base host platform and guest platform across traces; mock/test platform implementations that do not extend InternalTracePlatform; refactoring that broke platform-to-trace ownership.

Related errors


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