{"record":{"id":"b2aadd73c3b0e05f","repo":"NationalSecurityAgency/ghidra","slug":"cannot-modify-lifespan-of-default-data-unit","errorCode":null,"errorMessage":"Cannot modify lifespan of default data unit","messagePattern":"Cannot modify lifespan of default data unit","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/UndefinedDBTraceData.java","lineNumber":119,"sourceCode":"\t@Override\n\tpublic TraceAddressSnapRange getBounds() {\n\t\t// TODO: Cache this?\n\t\treturn new ImmutableTraceAddressSnapRange(getMinAddress(), getMaxAddress(), getLifespan());\n\t}\n\n\t@Override\n\tpublic Lifespan getLifespan() {\n\t\treturn lifespan;\n\t}\n\n\t@Override\n\tpublic long getStartSnap() {\n\t\treturn snap;\n\t}\n\n\t@Override\n\tpublic void setEndSnap(long endSnap) {\n\t\tthrow new UnsupportedOperationException(\"Cannot modify lifespan of default data unit\");\n\t}\n\n\t@Override\n\tpublic long getEndSnap() {\n\t\treturn snap;\n\t}\n\n\t@Override\n\tpublic Address getAddress() {\n\t\treturn address;\n\t}\n\n\t@Override\n\tpublic TraceThread getThread() {\n\t\treturn thread;\n\t}\n\n\t@Override","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/UndefinedDBTraceData.java#L101-L137","documentation":"Thrown by UndefinedDBTraceData.setEndSnap() — always, unconditionally. UndefinedDBTraceData has a fixed single-snap lifespan (Lifespan.at(snap)) that cannot be modified because the unit is ephemeral and not persisted. Attempting to change its lifespan is meaningless since the unit has no database representation to update.","triggerScenarios":"Calling setEndSnap(newEndSnap) on any UndefinedDBTraceData instance. This can happen when generic code that manages code unit lifespans encounters an undefined unit and tries to extend or modify its time range.","commonSituations":"Trace manipulation code that batch-updates code unit lifespans without distinguishing between defined and undefined units. Tools that extend code unit lifespans during trace merging or snap-range operations.","solutions":["Check the code unit type before calling setEndSnap(): verify it is not an UndefinedDBTraceData instance.","Only call setEndSnap() on defined code units (DBTraceInstruction, DBTraceData) that are backed by database entries.","Skip undefined units during lifespan management operations."],"exampleFix":"// before\nfor (DBTraceDataAdapter cu : units) {\n    cu.setEndSnap(newEndSnap);\n}\n\n// after\nfor (DBTraceDataAdapter cu : units) {\n    if (!(cu instanceof UndefinedDBTraceData)) {\n        cu.setEndSnap(newEndSnap);\n    }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Type guard: check before calling setEndSnap()\nstatic boolean hasMutableLifespan(DBTraceDataAdapter cu) {\n    return !(cu instanceof UndefinedDBTraceData);\n}\n\n// Usage:\nif (hasMutableLifespan(cu)) {\n    cu.setEndSnap(newEndSnap);\n}","tryCatchPattern":null,"preventionTips":["Check for UndefinedDBTraceData before calling setEndSnap().","Only modify lifespans on defined, persisted code units.","Undefined units always have Lifespan.at(snap) — a single snap."],"tags":["trace-database","undefined-data","unsupported-operation","unchecked-exception","lifespan"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}