{"record":{"id":"c5a10d58a2b5d7a1","repo":"NationalSecurityAgency/ghidra","slug":"space-does-not-exist","errorCode":null,"errorMessage":"Space does not exist","messagePattern":"Space does not exist","errorType":"exception","errorClass":"MemoryAccessException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java","lineNumber":290,"sourceCode":"\t}\n\n\t@Override\n\tpublic byte getByte(Address addr) throws MemoryAccessException {\n\t\ttry (LockHold hold = program.trace.lockRead()) {\n\t\t\treturn cache.read(addr);\n\t\t}\n\t}\n\n\t@Override\n\tpublic int getBytes(Address addr, byte[] b, int off, int len) throws MemoryAccessException {\n\t\ttry (LockHold hold = program.trace.lockRead()) {\n\t\t\tif (cache.canCache(addr, len)) {\n\t\t\t\treturn cache.read(addr, ByteBuffer.wrap(b, off, len));\n\t\t\t}\n\t\t\tAddressSpace as = addr.getAddressSpace();\n\t\t\tDBTraceMemorySpace space = program.trace.getMemoryManager().getMemorySpace(as, false);\n\t\t\tif (space == null) {\n\t\t\t\tthrow new MemoryAccessException(\"Space does not exist\");\n\t\t\t}\n\t\t\tlen = MathUtilities.unsignedMin(len, as.getMaxAddress().subtract(addr) + 1);\n\t\t\treturn space.getViewBytes(program.snap, addr, ByteBuffer.wrap(b, off, len));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setByte(Address addr, byte value) throws MemoryAccessException {\n\t\tDBTraceMemorySpace space = memoryManager.getMemorySpace(addr.getAddressSpace(), true);\n\t\tif (space.putBytes(snap, addr, ByteBuffer.wrap(new byte[] { value })) != 1) {\n\t\t\tthrow new MemoryAccessException();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void setBytes(Address addr, byte[] source, int sIndex, int size)\n\t\t\tthrows MemoryAccessException {\n\t\tDBTraceMemorySpace space = memoryManager.getMemorySpace(addr.getAddressSpace(), true);","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java#L272-L308","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nint n = mem.getBytes(addr, b, 0, len);\n\n// after\nDBTraceMemorySpace space = trace.getMemoryManager()\n    .getMemorySpace(addr.getAddressSpace(), false);\nif (space == null) {\n    // space not present in trace; handle missing memory\n    return 0;\n}\nint n = mem.getBytes(addr, b, 0, len);","handlingStrategy":"try-catch","validationCode":"// Check the memory space exists before reading bytes\nDBTraceMemorySpace space =\n    trace.getMemoryManager().getMemorySpace(addr.getAddressSpace(), false);\nif (space == null) {\n    // no state recorded for this space; cannot read\n    return -1;\n}","typeGuard":null,"tryCatchPattern":"try {\n    int n = mem.getBytes(addr, b, off, len);\n} catch (MemoryAccessException e) {\n    // space does not exist or read failed; handle missing memory\n}","preventionTips":["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."],"tags":["trace-modeling","memory","address-space","read","ghidra"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}