{"record":{"id":"83710bf74b329aed","repo":"NationalSecurityAgency/ghidra","slug":"instruction-has-incompatible-prototype-at-getst","errorCode":null,"errorMessage":"Instruction has incompatible prototype at: ({getStartSnap},{instructionAddress})","messagePattern":"Instruction has incompatible prototype at: \\((.+?),(.+?)\\)","errorType":"exception","errorClass":"UnknownContextException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceInstruction.java","lineNumber":871,"sourceCode":"\t@Override\n\tpublic ParserContext getParserContext(Address instructionAddress)\n\t\t\tthrows UnknownContextException, MemoryAccessException {\n\t\t// TODO: Why is this a method of Instruction? Seems should be of Listing.\n\t\t// NOTE: Taken from InstructionDB#getParserContext(Address) \n\t\t// Admittedly, I don't understand what it's for\n\t\tif (getAddress().equals(instructionAddress)) {\n\t\t\treturn getParserContext();\n\t\t}\n\t\tDBTraceInstruction instruction =\n\t\t\tspace.manager.instructions.getAt(getStartSnap(), instructionAddress);\n\t\tif (instruction == null) {\n\t\t\tthrow new UnknownContextException(\"Trace does not contain referenced instruction: (\" +\n\t\t\t\tgetStartSnap() + \",\" + instructionAddress + \")\");\n\t\t}\n\t\t// Ensure that prototype is the same implementation\n\t\tInstructionPrototype otherProto = instruction.getPrototype();\n\t\tif (!otherProto.getClass().equals(prototype.getClass())) {\n\t\t\tthrow new UnknownContextException(\"Instruction has incompatible prototype at: (\" +\n\t\t\t\tgetStartSnap() + \",\" + instructionAddress + \")\");\n\t\t}\n\t\treturn instruction.getParserContext();\n\t}\n}\n","sourceCodeStart":853,"sourceCodeEnd":877,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/DBTraceInstruction.java#L853-L877","documentation":"Thrown by DBTraceInstruction.getParserContext(Address instructionAddress) when an instruction exists at the referenced address but its InstructionPrototype implementation class differs from this instruction's prototype class. The method enforces prototype class equality via otherProto.getClass().equals(prototype.getClass()) to ensure compatible parser implementations. An UnknownContextException signals the prototype mismatch means the parser context cannot be safely shared.","triggerScenarios":"Calling getParserContext(instructionAddress) where the instruction at (getStartSnap(), instructionAddress) was created by a different language or disassembler, producing a different InstructionPrototype subclass (e.g., one from a different processor language or a different prototype implementation).","commonSituations":"When a trace contains instructions from multiple platforms/languages at the same snap, and the caller assumes prototype compatibility. When a trace was migrated or its language definition changed between sessions, causing prototype class mismatches.","solutions":["Verify prototype class compatibility before calling getParserContext: check the target instruction's getPrototype().getClass() matches the source instruction's.","Ensure all instructions at the referenced address were created with the same language/platform as the source instruction.","Catch UnknownContextException and obtain the parser context directly from the target instruction instead (target.getParserContext() with its own address)."],"exampleFix":"// before\nParserContext ctx = instruction.getParserContext(targetAddress);\n\n// after\nDBTraceInstruction target =\n    space.manager.instructions.getAt(instruction.getStartSnap(), targetAddress);\nif (target != null &&\n    target.getPrototype().getClass().equals(instruction.getPrototype().getClass())) {\n    ParserContext ctx = instruction.getParserContext(targetAddress);\n} else {\n    ParserContext ctx = target.getParserContext();\n}","handlingStrategy":"validation","validationCode":"// Verify prototype class compatibility\nDBTraceInstruction target = space.manager.instructions\n    .getAt(instruction.getStartSnap(), targetAddress);\nif (target == null ||\n    !target.getPrototype().getClass().equals(instruction.getPrototype().getClass())) {\n    // incompatible or missing; do not call getParserContext(targetAddress)\n}","typeGuard":null,"tryCatchPattern":"try {\n    ParserContext ctx = instruction.getParserContext(targetAddress);\n} catch (UnknownContextException e) {\n    // prototype mismatch or missing instruction\n    // obtain context directly from the target instruction instead\n}","preventionTips":["Ensure all instructions at referenced addresses use the same language and prototype class.","Do not mix instructions from different processor languages in cross-context lookups.","When the prototype class differs, call getParserContext() on the target instruction directly."],"tags":["instruction","trace-database","parser-context","prototype-mismatch","checked-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}