{"record":{"id":"85b2b5d9bb34b4b3","repo":"NationalSecurityAgency/ghidra","slug":"the-given-prefix-s-is-not-actually-a-prefix-of","errorCode":null,"errorMessage":"The given prefix (%s) is not actually a prefix of this (%s).","messagePattern":"The given prefix \\((.+?)\\) is not actually a prefix of this \\((.+?)\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/time/schedule/Sequence.java","lineNumber":365,"sourceCode":"\t * <p>\n\t * The returned step sequence should not be manipulated, since it may just be this sequence.\n\t * \n\t * @see #compareSeq(Sequence)\n\t * @param prefix the prefix\n\t * @return the relative sequence from prefix to this\n\t * @throws IllegalArgumentException if prefix is not a prefix of this sequence\n\t */\n\tpublic Sequence relativize(Sequence prefix) {\n\t\tif (prefix.isNop()) {\n\t\t\treturn this;\n\t\t}\n\t\tCompareResult comp = compareSeq(prefix);\n\t\tSequence result = new Sequence();\n\t\tif (comp == CompareResult.EQUALS) {\n\t\t\treturn result;\n\t\t}\n\t\tif (comp != CompareResult.REL_GT) {\n\t\t\tthrow new IllegalArgumentException(String.format(\n\t\t\t\t\"The given prefix (%s) is not actually a prefix of this (%s).\", prefix, this));\n\t\t}\n\n\t\tint lastStepIndex = prefix.steps.size() - 1;\n\t\tStep ancestorLast = prefix.steps.get(lastStepIndex);\n\t\tStep continuation = this.steps.get(lastStepIndex);\n\t\tresult.advance(continuation.subtract(ancestorLast));\n\t\tresult.steps.addAll(steps.subList(prefix.steps.size(), steps.size()));\n\t\treturn result;\n\t}\n\n\t/**\n\t * Compute to total number of ticks specified\n\t * \n\t * @return the total\n\t */\n\tpublic long totalTickCount() {\n\t\tlong count = 0;","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/model/time/schedule/Sequence.java#L347-L383","documentation":"Sequence.relativize computes the continuation from a prefix to this sequence. It requires that the argument is a true prefix — every step in the prefix must match the corresponding step in this sequence up to the prefix's length, with this sequence being strictly longer (CompareResult.REL_GT). If the argument is unrelated, shorter in the wrong way, or divergent, the exception is thrown.","triggerScenarios":"Calling relativize(prefix) where prefix diverges from this at some step index, or where prefix is actually longer than this. The compareSeq method returns UNREL_LT, UNREL_GT, or REL_LT instead of the required REL_GT.","commonSituations":"Computing the schedule delta between two snapshots or emulated positions where one schedule was not derived from the other. Passing a schedule from a different thread ordering or a different stepping path. Using relativize on schedules that share a common ancestor but where the prefix has already branched.","solutions":["Verify the prefix is actually a prefix of this sequence using compareSeq before calling relativize: if (compareSeq(prefix) == CompareResult.REL_GT)","Ensure both schedules were constructed from the same base snapshot with only appended steps differing","If the schedules are unrelated, compute the difference from a common ancestor instead","Use compareSeq to inspect the relationship and handle REL_LT / UNREL_* cases separately"],"exampleFix":"// before\nSequence diff = fullSchedule.relativize(baseSchedule);\n// after\nCompareResult rel = fullSchedule.compareSeq(baseSchedule);\nif (rel == CompareResult.REL_GT) {\n    Sequence diff = fullSchedule.relativize(baseSchedule);\n} else {\n    // re-derive from common ancestor\n}","handlingStrategy":"validation","validationCode":"CompareResult rel = fullSequence.compareSeq(prefix);\nif (rel == CompareResult.REL_GT) {\n    Sequence diff = fullSequence.relativize(prefix);\n} else {\n    // prefix is not a prefix; handle fallback\n}","typeGuard":"// N/A — Sequence relationship is runtime, not type-level","tryCatchPattern":"try {\n    Sequence diff = fullSequence.relativize(prefix);\n} catch (IllegalArgumentException e) {\n    // recompute from a known common ancestor\n}","preventionTips":["Check compareSeq before calling relativize","Ensure schedules share a common base before relativizing","Test prefix relationships with small examples before production use"],"tags":["ghidra","trace-schedule","sequence","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}