{"record":{"id":"0ad226b11b1255e4","repo":"NationalSecurityAgency/ghidra","slug":"register-register-does-not-map-to-space-space","errorCode":null,"errorMessage":"Register {register} does not map to space {space}'s physical space ({space.getPhysicalSpace})","messagePattern":"Register (.+?) does not map to space (.+?)'s physical space \\((.+?)\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/InternalTracePlatform.java","lineNumber":69,"sourceCode":"\tDBTraceGuestLanguage getLanguageEntry();\n\n\t@Override\n\tdefault AddressFactory getAddressFactory() {\n\t\treturn TracePlatform.super.getAddressFactory();\n\t}\n\n\t@Override\n\tdefault AddressRange getConventionalRegisterRange(AddressSpace space, Register register) {\n\t\tAddressRange result = mapGuestToHost(TraceRegisterUtils.rangeForRegister(register));\n\t\tif (result == null) {\n\t\t\tthrow new IllegalArgumentException(\"Register \" + register + \" is not mapped\");\n\t\t}\n\t\tif (space == null) {\n\t\t\treturn result;\n\t\t}\n\t\tif (register.getAddressSpace().isRegisterSpace()) {\n\t\t\tif (result.getAddressSpace() != space.getPhysicalSpace()) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Register \" + register + \" does not map to space \" + space +\n\t\t\t\t\t\t\"'s physical space (\" + space.getPhysicalSpace() + \")\");\n\t\t\t}\n\t\t\treturn new AddressRangeImpl(\n\t\t\t\tspace.getOverlayAddress(result.getMinAddress()),\n\t\t\t\tspace.getOverlayAddress(result.getMaxAddress()));\n\t\t}\n\t\tif (result.getAddressSpace() != space) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\"Memory-mapped register \" + register + \" does not map to space \" + space);\n\t\t}\n\t\treturn result;\n\t}\n\n\tdefault List<String> listRegNames(Register register) {\n\t\tSet<String> result = new LinkedHashSet<>();\n\t\tresult.add(register.getName());\n\t\tresult.add(register.getName().toUpperCase());","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/InternalTracePlatform.java#L51-L87","documentation":"Thrown by getConventionalRegisterRange when a register that lives in the register address space is mapped (via mapGuestToHost) to a host address space that does not match the requested space's physical space. This indicates a mismatch between the guest register's mapped host location and the overlay/physical space the caller asked for. The method is validating that a guest-platform register, after translation to host coordinates, still belongs to the correct physical address space before returning an overlay-adjusted range.","triggerScenarios":"Calling platform.getConventionalRegisterRange(space, register) where 'space' is an overlay space (or any space with a distinct physical space) and 'register' is a true register-space register whose guest-to-host mapping resolves into a different physical space than space.getPhysicalSpace(). This happens when the caller passes a register whose host-side mapping lives in register space but the supplied 'space' parameter points to a memory overlay space (or vice versa).","commonSituations":"Mixing up overlay spaces and their physical spaces when querying register values; using a register obtained from the wrong guest platform; passing a memory-overlay space where a register-space-derived space was expected; incorrect TraceRegisterUtils mappings after a language/platform version change that altered register layouts.","solutions":["Verify that the 'space' argument matches the address space where the register actually maps on the host — call register.getAddressSpace() and compare its physical space to space.getPhysicalSpace() before invoking getConventionalRegisterRange.","If you need the host register range regardless of overlay, pass null for the 'space' parameter (the method returns the raw host range when space == null).","Ensure the register object comes from the same platform/language that produced the mapping — do not cross guest platforms.","Check for stale register mappings after upgrading the guest language definition (.sleigh / .ldefs)."],"exampleFix":"// before\nAddressRange range = platform.getConventionalRegisterRange(overlaySpace, register);\n\n// after — pass null to get the raw host mapping, or verify the space first\nAddressSpace regPhys = register.getAddressSpace().getPhysicalSpace();\nif (regPhys == overlaySpace.getPhysicalSpace()) {\n    AddressRange range = platform.getConventionalRegisterRange(overlaySpace, register);\n} else {\n    AddressRange range = platform.getConventionalRegisterRange(null, register);\n}","handlingStrategy":"validation","validationCode":"// Before calling getConventionalRegisterRange\nAddressSpace regSpace = register.getAddressSpace();\nif (regSpace.isRegisterSpace()) {\n    if (space != null && regSpace.getPhysicalSpace() != space.getPhysicalSpace()) {\n        // pass null to get raw host range, or fix the space argument\n        return platform.getConventionalRegisterRange(null, register);\n    }\n}\nreturn platform.getConventionalRegisterRange(space, register);","typeGuard":"// Check register/space compatibility before the call\nstatic boolean registerSpaceMatches(Register register, AddressSpace space) {\n    if (space == null) return true;\n    if (register.getAddressSpace().isRegisterSpace()) {\n        return register.getAddressSpace().getPhysicalSpace() == space.getPhysicalSpace();\n    }\n    return register.getAddressSpace() == space;\n}","tryCatchPattern":"try {\n    return platform.getConventionalRegisterRange(space, register);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"does not map to space\")) {\n        // Fallback: get raw host mapping without space validation\n        return platform.getConventionalRegisterRange(null, register);\n    }\n    throw e;\n}","preventionTips":["Always verify register.getAddressSpace().getPhysicalSpace() matches space.getPhysicalSpace() for register-space registers before calling.","Pass null for space when you only need the raw host-mapped range without overlay adjustment.","Ensure register objects come from the same guest platform that owns the mapping."],"tags":["address-space","register-mapping","guest-platform","trace-modeling"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}