NationalSecurityAgency/ghidra · error · IllegalArgumentException

Platform and prototype disagree in language

Error message

Platform and prototype disagree in language

What it means

Thrown by DBTraceInstructionsView.doCreate() when the InternalTracePlatform's language and the InstructionPrototype's language are not the exact same object instance (checked via !=). This is an IllegalArgumentException (unchecked), signalling a programming error: the platform and prototype must originate from the same Language definition. The create() method delegates to doCreate(), so any instruction creation path can trigger this.

Source

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

	 * @param context the initial context for parsing the instruction
	 * @param length instruction byte-length (must be in the range 0..prototype.getLength()). If
	 *            smaller than the prototype length it must have a value no greater than 7,
	 *            otherwise an error will be thrown. A value of 0 or greater-than-or-equal the
	 *            prototype length will be ignored and not impose and override length. The length
	 *            value must be a multiple of the {@link Language#getInstructionAlignment()
	 *            instruction alignment} .
	 * @return the newly created instruction.
	 * @throws CodeUnitInsertionException thrown if the new Instruction would overlap and existing
	 *             {@link CodeUnit} or the specified {@code length} is unsupported.
	 * @throws IllegalArgumentException if a negative {@code length} is specified.
	 * @throws AddressOverflowException if the instruction would fall off the address space
	 */
	protected DBTraceInstruction doCreate(Lifespan lifespan, Address address,
			InternalTracePlatform platform, InstructionPrototype prototype,
			ProcessorContextView context, int length)
			throws CodeUnitInsertionException, AddressOverflowException {
		if (platform.getLanguage() != prototype.getLanguage()) {
			throw new IllegalArgumentException("Platform and prototype disagree in language");
		}

		int forcedLengthOverride = InstructionDB.checkLengthOverride(length, prototype);
		if (length == 0) {
			length = prototype.getLength();
		}
		Address endAddress = address.addNoWrap(length - 1);
		AddressRangeImpl createdRange = new AddressRangeImpl(address, endAddress);

		// Truncate, then check that against existing code units.
		long endSnap = computeTruncatedMax(lifespan, null, createdRange);
		TraceAddressSnapRange tasr =
			new ImmutableTraceAddressSnapRange(createdRange, lifespan.withMax(endSnap));

		if (!space.undefinedData.coversRange(tasr)) {
			// TODO: Figure out the conflicting unit or snap boundary?
			throw new CodeUnitInsertionException("Code units cannot overlap");
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure the platform and prototype are sourced from the same Language: use platform.getLanguage() to obtain the language for both the platform and any prototype creation.
  2. If working with guest platforms, use the correct TracePlatform (trace.getPlatformManager().getPlatform(language)) that matches the prototype's language.
  3. Add an assertion before create(): assert platform.getLanguage() == prototype.getLanguage().

Example fix

// before
DBTraceInstruction instr = view.create(lifespan, addr, platform, prototype, ctx, 0);

// after
if (platform.getLanguage() != prototype.getLanguage()) {
    platform = trace.getPlatformManager().getPlatform(prototype.getLanguage());
}
DBTraceInstruction instr = view.create(lifespan, addr, platform, prototype, ctx, 0);
Defensive patterns

Strategy: validation

Validate before calling

// Verify platform and prototype language agreement before create
if (platform.getLanguage() != prototype.getLanguage()) {
    // resolve the correct platform for this prototype's language
    platform = trace.getPlatformManager()
        .getPlatform(prototype.getLanguage());
}
// now safe to call create

Prevention

When it happens

Trigger: Calling DBTraceInstructionsView.create(...) or doCreate(...) with a TracePlatform whose getLanguage() returns a different Language object than the InstructionPrototype's getLanguage(). This happens when the platform was configured for one processor (e.g., x86:LE:64:default) while the prototype was derived from a different language (e.g., ARM or a different x86 variant).

Common situations: Mixing guest and host platforms in a trace that supports guest platforms — using a host platform with a guest-derived prototype, or vice versa. Loading a prototype from a cached Sleigh language that differs from the platform's active language. Copying instructions between traces with different language configurations.

Related errors


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