{"record":{"id":"d888743c652bfd59","repo":"NationalSecurityAgency/ghidra","slug":"space-must-be-a-memory-register-or-no-address-sp","errorCode":null,"errorMessage":"Space must be a memory, register, or NO_ADDRESS space","messagePattern":"Space must be a memory, register, or NO_ADDRESS space","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/space/AbstractDBTraceSpaceBasedManager.java","lineNumber":142,"sourceCode":"\t\tAddressFactory factory = trace.getBaseAddressFactory();\n\t\tList<TabledSpace> result = new ArrayList<>();\n\t\tfor (DBTraceSpaceEntry ent : spaceStore.asMap().values()) {\n\t\t\tAddressSpace space = getSpaceByName(factory, ent.spaceName);\n\t\t\tif (space == null) {\n\t\t\t\tMsg.error(this, \"Space \" + ent.spaceName + \" does not exist in trace (language=\" +\n\t\t\t\t\tbaseLanguage + \").\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult.add(new TabledSpace(ent, space));\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected M getForSpace(AddressSpace space, boolean createIfAbsent) {\n\t\ttrace.assertValidSpace(Objects.requireNonNull(space));\n\t\tif (!space.isMemorySpace() && !space.isRegisterSpace() &&\n\t\t\tspace != Address.NO_ADDRESS.getAddressSpace()) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Space must be a memory, register, or NO_ADDRESS space\");\n\t\t}\n\t\tif (!createIfAbsent) {\n\t\t\ttry (LockHold hold = LockHold.lock(lock.readLock())) {\n\t\t\t\treturn spaces.get(space);\n\t\t\t}\n\t\t}\n\t\ttry (LockHold hold = LockHold.lock(lock.writeLock())) {\n\t\t\treturn spaces.computeIfAbsent(space, s -> {\n\t\t\t\t// NOTE: Require caller to start transaction\n\t\t\t\ttry {\n\t\t\t\t\tDBTraceSpaceEntry ent = spaceStore.create();\n\t\t\t\t\tent.set(space.getName(), -1, 0);\n\t\t\t\t\treturn createSpace(space, ent);\n\t\t\t\t}\n\t\t\t\tcatch (VersionException e) {\n\t\t\t\t\tthrow new AssertionError(e);\n\t\t\t\t}","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/space/AbstractDBTraceSpaceBasedManager.java#L124-L160","documentation":"Thrown by AbstractDBTraceSpaceBasedManager.getForSpace when the given AddressSpace is neither a memory space, a register space, nor the special Address.NO_ADDRESS space. Trace space-based managers (memory, registers, code units, etc.) only operate on these three categories. Passing a constant/unique/hash/custom address space is rejected to keep per-space storage meaningful.","triggerScenarios":"Calling a space-scoped API with addrSpace == constantSpace, a unique space, or a user-defined non-memory address space. Passing the address space derived from a constant address into a memory/register manager.","commonSituations":"Tooling that iterates over all AddressSpaces from a language and forgets to skip constant/unique spaces; mis-routing a register address into a code path expecting memory.","solutions":["Guard the call: if (!space.isMemorySpace() && !space.isRegisterSpace() && space != Address.NO_ADDRESS.getAddressSpace()) skip it.","Use the correct manager for the address type (register addresses -> register manager).","Resolve the physical/overlay space before calling getForSpace."],"exampleFix":"// before\nmgr.getForSpace(addr.getAddressSpace(), true);\n// after\nAddressSpace sp = addr.getAddressSpace();\nif (sp.isMemorySpace() || sp.isRegisterSpace() ||\n    sp == Address.NO_ADDRESS.getAddressSpace()) {\n    mgr.getForSpace(sp, true);\n}","handlingStrategy":"validation","validationCode":"AddressSpace sp = ...;\nif (!sp.isMemorySpace() && !sp.isRegisterSpace() &&\n    sp != Address.NO_ADDRESS.getAddressSpace()) {\n    return; // or route elsewhere\n}\nmgr.getForSpace(sp, createIfAbsent);","typeGuard":"static boolean isTraceSpace(AddressSpace sp) {\n    return sp.isMemorySpace() || sp.isRegisterSpace()\n        || sp == Address.NO_ADDRESS.getAddressSpace();\n}","tryCatchPattern":null,"preventionTips":["Skip constant/unique/custom address spaces before space-scoped calls.","Match the address type to the correct manager."],"tags":["address-space","memory","register","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}