NationalSecurityAgency/ghidra · error · MemoryAccessException
Space does not exist
Error message
Space does not exist
What it means
Thrown as MemoryAccessException by getBytes when the AddressSpace of the requested address has no backing DBTraceMemorySpace in the trace (getMemorySpace returns null with create=false). This means no memory state was ever recorded for that address space, so bytes cannot be read.
Source
Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java:290
}
@Override
public byte getByte(Address addr) throws MemoryAccessException {
try (LockHold hold = program.trace.lockRead()) {
return cache.read(addr);
}
}
@Override
public int getBytes(Address addr, byte[] b, int off, int len) throws MemoryAccessException {
try (LockHold hold = program.trace.lockRead()) {
if (cache.canCache(addr, len)) {
return cache.read(addr, ByteBuffer.wrap(b, off, len));
}
AddressSpace as = addr.getAddressSpace();
DBTraceMemorySpace space = program.trace.getMemoryManager().getMemorySpace(as, false);
if (space == null) {
throw new MemoryAccessException("Space does not exist");
}
len = MathUtilities.unsignedMin(len, as.getMaxAddress().subtract(addr) + 1);
return space.getViewBytes(program.snap, addr, ByteBuffer.wrap(b, off, len));
}
}
@Override
public void setByte(Address addr, byte value) throws MemoryAccessException {
DBTraceMemorySpace space = memoryManager.getMemorySpace(addr.getAddressSpace(), true);
if (space.putBytes(snap, addr, ByteBuffer.wrap(new byte[] { value })) != 1) {
throw new MemoryAccessException();
}
}
@Override
public void setBytes(Address addr, byte[] source, int sIndex, int size)
throws MemoryAccessException {
DBTraceMemorySpace space = memoryManager.getMemorySpace(addr.getAddressSpace(), true);View on GitHub (pinned to d5f144c24d)
Solutions
- Before reading, check getMemoryManager().getMemorySpace(addr.getAddressSpace(), false) != null.
- Ensure the trace actually records state for the target address space (write bytes or set state to populate it).
- Use the correct platform/address-space for the traced target.
Example fix
// before
int n = mem.getBytes(addr, b, 0, len);
// after
DBTraceMemorySpace space = trace.getMemoryManager()
.getMemorySpace(addr.getAddressSpace(), false);
if (space == null) {
// space not present in trace; handle missing memory
return 0;
}
int n = mem.getBytes(addr, b, 0, len); Defensive patterns
Strategy: try-catch
Validate before calling
// Check the memory space exists before reading bytes
DBTraceMemorySpace space =
trace.getMemoryManager().getMemorySpace(addr.getAddressSpace(), false);
if (space == null) {
// no state recorded for this space; cannot read
return -1;
} Try / catch
try {
int n = mem.getBytes(addr, b, off, len);
} catch (MemoryAccessException e) {
// space does not exist or read failed; handle missing memory
} Prevention
- Check getMemorySpace(as, false) != null before reading.
- Ensure the trace records state for the target address space before querying.
- Use the correct platform/address-space for the traced target.
When it happens
Trigger: Calling getBytes(addr, b, off, len) on a trace program view's memory for an address in an address space that has never been written to or initialized in the trace.
Common situations: Reading from a register space, overlay space, or RAM space that was never populated during tracing/emulation. Accessing an address space that belongs to a different architecture/platform than the one traced. Querying memory before the trace has recorded any state for that space.
Related errors
- Code unit would extend beyond address space
- All trace memory is initialized
- Mapped blocks are not supported in traces
- Memory addresses cannot be associated with a thread
- No such address space: %s
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/c5a10d58a2b5d7a1.
Report an issue: GitHub.