NationalSecurityAgency/ghidra · error · IllegalArgumentException

Given bookmark is not part of this trace

Error message

Given bookmark is not part of this trace

What it means

Thrown as IllegalArgumentException by removeBookmark when the passed Bookmark object is not an instance of DBTraceBookmark. The trace bookmark manager only operates on trace-owned bookmark objects; a bookmark from a regular Program or an unrelated implementation cannot be managed by the trace.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/DBTraceProgramViewBookmarkManager.java:128

	}

	protected void doDeleteOrTruncateLifespan(TraceBookmark bm) {
		Lifespan lifespan = bm.getLifespan();
		if (!lifespan.contains(program.snap)) {
			throw new IllegalArgumentException("Given bookmark is not present at this view's snap");
		}
		if (lifespan.lmin() == program.snap) {
			bm.delete();
		}
		else {
			bm.setLifespan(lifespan.intersect(Lifespan.before(program.snap)));
		}
	}

	@Override
	public void removeBookmark(Bookmark bookmark) {
		if (!(bookmark instanceof DBTraceBookmark)) {
			throw new IllegalArgumentException("Given bookmark is not part of this trace");
		}
		DBTraceBookmark dbBookmark = (DBTraceBookmark) bookmark;
		if (dbBookmark.getTrace() != program.trace) {
			throw new IllegalArgumentException("Given bookmark is not part of this trace");
		}
		doDeleteOrTruncateLifespan(dbBookmark);
	}

	@Override
	public void removeBookmarks(String type) {
		try (LockHold hold = program.trace.lockWrite()) {
			for (DBTraceBookmark bm : bookmarkManager.getBookmarksByType(type)) {
				if (!bm.getLifespan().contains(program.snap)) {
					continue;
				}
				doDeleteOrTruncateLifespan(bm);
			}
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Only pass bookmarks obtained from the trace's own bookmark manager to removeBookmark.
  2. Type-check: verify bookmark instanceof DBTraceBookmark before calling.
  3. If you have a static-program bookmark, find or create the corresponding trace bookmark first.

Example fix

// before
bookmarkManager.removeBookmark(someProgramBookmark);

// after
if (bookmark instanceof DBTraceBookmark) {
    bookmarkManager.removeBookmark((DBTraceBookmark) bookmark);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (bookmark instanceof DBTraceBookmark) {
    bookmarkManager.removeBookmark((DBTraceBookmark) bookmark);
}

Type guard

static boolean isTraceBookmark(Bookmark b) {
    return b instanceof DBTraceBookmark;
}

Prevention

When it happens

Trigger: Calling removeBookmark with a Bookmark object obtained from a different (non-trace) Program, or a mock/test bookmark that is not a DBTraceBookmark.

Common situations: Mixing bookmarks from a static Program with the trace program view. Passing a Program bookmark to the trace bookmark manager. Using a generic Bookmark handle across program types.

Related errors


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