{"record":{"id":"ce1b5f8f4e5ad21b","repo":"NationalSecurityAgency/ghidra","slug":"range-overlaps-existing-guest-mapped-range-s","errorCode":null,"errorMessage":"Range overlaps existing guest mapped range(s)","messagePattern":"Range overlaps existing guest mapped range\\(s\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatform.java","lineNumber":275,"sourceCode":"\tpublic void delete(TaskMonitor monitor) throws CancelledException {\n\t\tmanager.deleteGuestPlatform(this, monitor);\n\t\t// TODO: Delete language once no platform uses it?\n\t}\n\n\t@Override\n\tpublic DBTraceGuestPlatformMappedRange addMappedRange(Address hostStart, Address guestStart,\n\t\t\tlong length) throws AddressOverflowException {\n\t\tDBTraceGuestPlatformMappedRange mappedRange;\n\t\ttry (LockHold hold = LockHold.lock(manager.lock.writeLock())) {\n\t\t\tAddress hostEnd = hostStart.addWrap(length - 1);\n\t\t\tif (hostAddressSet.intersects(hostStart, hostEnd)) {\n\t\t\t\t// TODO: Check for compatibility and extend?\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Range overlaps existing host mapped range(s) for this guest language\");\n\t\t\t}\n\t\t\tAddress guestEnd = guestStart.addWrap(length - 1);\n\t\t\tif (guestAddressSet.intersects(guestStart, guestEnd)) {\n\t\t\t\tthrow new IllegalArgumentException(\"Range overlaps existing guest mapped range(s)\");\n\t\t\t}\n\t\t\tmappedRange = manager.rangeMappingStore.create();\n\t\t\tmappedRange.set(hostStart, this, guestStart, length);\n\t\t\trangesByHostAddress.put(hostStart, mappedRange);\n\t\t\trangesByGuestAddress.put(guestStart, mappedRange);\n\t\t\thostAddressSet.add(mappedRange.getHostRange());\n\t\t\tguestAddressSet.add(mappedRange.getGuestRange());\n\t\t}\n\t\tmanager.trace.setChanged(new TraceChangeRecord<>(TraceEvents.PLATFORM_MAPPING_ADDED,\n\t\t\thostStart.getAddressSpace(), this, null, mappedRange));\n\t\treturn mappedRange;\n\t}\n\n\tprotected Address computeNextRegisterMin() {\n\t\tAddress regMax = manager.hostPlatform.getLanguage()\n\t\t\t\t.getAddressFactory()\n\t\t\t\t.getRegisterSpace()\n\t\t\t\t.getMaxAddress();","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatform.java#L257-L293","documentation":"After the host-overlap check in addMappedRange, the code computes guestEnd and tests guestAddressSet.intersects(guestStart, guestEnd); overlap on the guest side throws IllegalArgumentException(\"Range overlaps existing guest mapped range(s)\"). Guest windows for a platform must also be mutually disjoint.","triggerScenarios":"Adding a second mapping whose guest span overlaps an existing one for the same platform; re-mapping guest addresses already covered.","commonSituations":"Emulation reconfiguration that reuses guest addresses; partial cleanup leaving a prior guest range in place.","solutions":["Verify the guest range is disjoint from guestAddressSet before mapping.","Adjust guestStart and/or length to avoid overlap.","Remove the conflicting prior guest mapping first."],"exampleFix":"// before\nplatform.addMappedRange(hostStart, guestStart, length);\n\n// after\nAddress guestEnd = guestStart.addWrap(length - 1);\nif (guestAddressSet.intersects(guestStart, guestEnd)) {\n    throw new IllegalStateException(\"guest range conflicts; remove existing first\");\n}\nplatform.addMappedRange(hostStart, guestStart, length);","handlingStrategy":"validation","validationCode":"Address guestEnd = guestStart.addWrap(length - 1);\nif (guestAddressSet.intersects(guestStart, guestEnd)) {\n    // adjust guestStart/length or remove the conflicting prior mapping\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a disjoint guest-range set per platform and check before mapping.","Remove obsolete mappings before adding overlapping replacements.","Validate both host and guest sides in one preflight step."],"tags":["memory-mapping","overlap","guest-platform"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}