{"record":{"id":"aa09cf048f02c908","repo":"NationalSecurityAgency/ghidra","slug":"platform-and-prototype-disagree-in-language","errorCode":null,"errorMessage":"Platform and prototype disagree in language","messagePattern":"Platform and prototype disagree in language","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceInstructionsView.java","lineNumber":365,"sourceCode":"\t * @param context the initial context for parsing the instruction\n\t * @param length instruction byte-length (must be in the range 0..prototype.getLength()). If\n\t *            smaller than the prototype length it must have a value no greater than 7,\n\t *            otherwise an error will be thrown. A value of 0 or greater-than-or-equal the\n\t *            prototype length will be ignored and not impose and override length. The length\n\t *            value must be a multiple of the {@link Language#getInstructionAlignment()\n\t *            instruction alignment} .\n\t * @return the newly created instruction.\n\t * @throws CodeUnitInsertionException thrown if the new Instruction would overlap and existing\n\t *             {@link CodeUnit} or the specified {@code length} is unsupported.\n\t * @throws IllegalArgumentException if a negative {@code length} is specified.\n\t * @throws AddressOverflowException if the instruction would fall off the address space\n\t */\n\tprotected DBTraceInstruction doCreate(Lifespan lifespan, Address address,\n\t\t\tInternalTracePlatform platform, InstructionPrototype prototype,\n\t\t\tProcessorContextView context, int length)\n\t\t\tthrows CodeUnitInsertionException, AddressOverflowException {\n\t\tif (platform.getLanguage() != prototype.getLanguage()) {\n\t\t\tthrow new IllegalArgumentException(\"Platform and prototype disagree in language\");\n\t\t}\n\n\t\tint forcedLengthOverride = InstructionDB.checkLengthOverride(length, prototype);\n\t\tif (length == 0) {\n\t\t\tlength = prototype.getLength();\n\t\t}\n\t\tAddress endAddress = address.addNoWrap(length - 1);\n\t\tAddressRangeImpl createdRange = new AddressRangeImpl(address, endAddress);\n\n\t\t// Truncate, then check that against existing code units.\n\t\tlong endSnap = computeTruncatedMax(lifespan, null, createdRange);\n\t\tTraceAddressSnapRange tasr =\n\t\t\tnew ImmutableTraceAddressSnapRange(createdRange, lifespan.withMax(endSnap));\n\n\t\tif (!space.undefinedData.coversRange(tasr)) {\n\t\t\t// TODO: Figure out the conflicting unit or snap boundary?\n\t\t\tthrow new CodeUnitInsertionException(\"Code units cannot overlap\");\n\t\t}","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceInstructionsView.java#L347-L383","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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.","If working with guest platforms, use the correct TracePlatform (trace.getPlatformManager().getPlatform(language)) that matches the prototype's language.","Add an assertion before create(): assert platform.getLanguage() == prototype.getLanguage()."],"exampleFix":"// before\nDBTraceInstruction instr = view.create(lifespan, addr, platform, prototype, ctx, 0);\n\n// after\nif (platform.getLanguage() != prototype.getLanguage()) {\n    platform = trace.getPlatformManager().getPlatform(prototype.getLanguage());\n}\nDBTraceInstruction instr = view.create(lifespan, addr, platform, prototype, ctx, 0);","handlingStrategy":"validation","validationCode":"// Verify platform and prototype language agreement before create\nif (platform.getLanguage() != prototype.getLanguage()) {\n    // resolve the correct platform for this prototype's language\n    platform = trace.getPlatformManager()\n        .getPlatform(prototype.getLanguage());\n}\n// now safe to call create","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always source the platform and prototype from the same Language object.","When working with guest platforms, use getPlatform(prototype.getLanguage()) to get the matching platform.","Add an assertion: assert platform.getLanguage() == prototype.getLanguage()."],"tags":["instruction","trace-database","language-mismatch","unchecked-exception","platform"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}