NationalSecurityAgency/ghidra · critical · IOException

Trace Bytes table is corrupt

Error message

Trace Bytes table is corrupt

What it means

Thrown by DBTraceMemoryBlockEntry.findAssignedBuffer() when the block has a valid bufferKey (!= -1) but the buffer store returns null for that key via space.bufferStore.getObjectAt(bufferKey). This indicates the trace's Bytes table is internally inconsistent: a block references a buffer that no longer exists. An IOException (checked) signals database corruption that cannot be recovered programmatically.

Source

Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/memory/DBTraceMemoryBlockEntry.java:172

	protected DBTraceMemoryBufferEntry findFreeBuffer() throws IOException {
		DBTraceMemoryBufferEntry ent = findFreeBufferInPast();
		if (ent != null) {
			return ent;
		}
		ent = findFreeBufferInFuture();
		if (ent != null) {
			return ent;
		}
		return allocateNewBuffer();
	}

	protected DBTraceMemoryBufferEntry findAssignedBuffer() throws IOException {
		if (bufferKey == -1) {
			return null;
		}
		DBTraceMemoryBufferEntry bufEnt = space.bufferStore.getObjectAt(bufferKey);
		if (bufEnt == null) {
			throw new IOException("Trace Bytes table is corrupt");
		}
		return bufEnt;
	}

	protected static boolean isZeroes(ByteBuffer buf, int len) {
		int pos = buf.position();
		for (int i = 0; i < len; i++) {
			if (buf.get(pos + i) != 0) {
				return false;
			}
		}
		return true;
	}

	public int setBytes(ByteBuffer buf, int dstOffset, int len) throws IOException {
		DBTraceMemoryBufferEntry bufEnt = findAssignedBuffer();
		if (bufEnt == null) {
			if (isZeroes(buf, len)) {

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Restore the trace database from a known-good backup.
  2. Re-create the trace by re-importing or re-recording the debugging session.
  3. Run Ghidra's database repair/upgrade tools if available.
  4. If the corruption is limited to one block, consider clearing and re-recording memory for that address range.
Defensive patterns

Strategy: fallback

Try / catch

try {
    byte[] bytes = memory.getBytes(addr, buf);
} catch (IOException e) {
    if (e.getMessage().contains("corrupt")) {
        // trace database corruption — restore from backup or re-record
        logger.severe("Trace database corruption detected: " + e.getMessage());
    }
}

Prevention

When it happens

Trigger: Reading trace memory when a DBTraceMemoryBlockEntry references a bufferKey in the buffer store, but the DBTraceMemoryBufferEntry at that key has been deleted or was never written. This occurs during getBytes(), findAssignedBuffer(), or buffer allocation paths.

Common situations: Database file corruption due to improper shutdown, disk failure, or concurrent access issues. Trace database was partially written or interrupted during save. Version mismatch or incomplete upgrade of the trace database format. Manual editing or external corruption of the .gdb database files.

Related errors


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