NationalSecurityAgency/ghidra · error · UnsupportedOperationException

Cannot modify lifespan of default data unit

Error message

Cannot modify lifespan of default data unit

What it means

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.

Source

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

	@Override
	public TraceAddressSnapRange getBounds() {
		// TODO: Cache this?
		return new ImmutableTraceAddressSnapRange(getMinAddress(), getMaxAddress(), getLifespan());
	}

	@Override
	public Lifespan getLifespan() {
		return lifespan;
	}

	@Override
	public long getStartSnap() {
		return snap;
	}

	@Override
	public void setEndSnap(long endSnap) {
		throw new UnsupportedOperationException("Cannot modify lifespan of default data unit");
	}

	@Override
	public long getEndSnap() {
		return snap;
	}

	@Override
	public Address getAddress() {
		return address;
	}

	@Override
	public TraceThread getThread() {
		return thread;
	}

	@Override

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Check the code unit type before calling setEndSnap(): verify it is not an UndefinedDBTraceData instance.
  2. Only call setEndSnap() on defined code units (DBTraceInstruction, DBTraceData) that are backed by database entries.
  3. Skip undefined units during lifespan management operations.

Example fix

// before
for (DBTraceDataAdapter cu : units) {
    cu.setEndSnap(newEndSnap);
}

// after
for (DBTraceDataAdapter cu : units) {
    if (!(cu instanceof UndefinedDBTraceData)) {
        cu.setEndSnap(newEndSnap);
    }
}
Defensive patterns

Strategy: type-guard

Type guard

// Type guard: check before calling setEndSnap()
static boolean hasMutableLifespan(DBTraceDataAdapter cu) {
    return !(cu instanceof UndefinedDBTraceData);
}

// Usage:
if (hasMutableLifespan(cu)) {
    cu.setEndSnap(newEndSnap);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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