{"record":{"id":"bf0ef9d9c1bcc75b","repo":"NationalSecurityAgency/ghidra","slug":"conflicting-mappings-for","errorCode":null,"errorMessage":"Conflicting mappings for {}","messagePattern":"Conflicting mappings for (.+?)","errorType":"exception","errorClass":"TraceConflictedMappingException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingUtils.java","lineNumber":234,"sourceCode":"\t\t\t\t\textrema.getMin().getOffset(), extrema.getMax().getOffset());\n\t\t\tif (fromRange == null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\taddMapping(\n\t\t\t\t\tnew DefaultTraceLocation(from, null, lifespan, fromRange.getMinAddress()),\n\t\t\t\t\tnew ProgramLocation(toProgram, extrema.getMin()), fromRange.getLength(),\n\t\t\t\t\ttruncateExisting);\n\t\t\t}\n\t\t\tcatch (TraceConflictedMappingException e) {\n\t\t\t\tfailures.add(fromRange);\n\t\t\t\tconflicts.addAll(e.getConflicts());\n\t\t\t\tMsg.error(DebuggerStaticMappingUtils.class,\n\t\t\t\t\t\"Could not add identity mapping \" + fromRange + \": \" + e.getMessage());\n\t\t\t}\n\t\t}\n\t\tif (!failures.isEmpty()) {\n\t\t\tthrow new TraceConflictedMappingException(\"Conflicting mappings for \" + failures,\n\t\t\t\tconflicts);\n\t\t}\n\t}\n\n\tprotected static AddressRange clippedRange(Trace trace, String spaceName, long min,\n\t\t\tlong max) {\n\t\tAddressSpace space = trace.getBaseAddressFactory().getAddressSpace(spaceName);\n\t\tif (space == null) {\n\t\t\treturn null;\n\t\t}\n\t\tAddress spaceMax = space.getMaxAddress();\n\t\tif (Long.compareUnsigned(min, spaceMax.getOffset()) > 0) {\n\t\t\treturn null;\n\t\t}\n\t\tif (Long.compareUnsigned(max, spaceMax.getOffset()) > 0) {\n\t\t\treturn new AddressRangeImpl(space.getAddress(min), spaceMax);\n\t\t}\n\t\treturn new AddressRangeImpl(space.getAddress(min), space.getAddress(max));","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingUtils.java#L216-L252","documentation":"When adding multiple identity mappings in a loop, addMapping(..., truncateExisting=false) is called per range. Any range that hits an overlapping existing mapping throws TraceConflictedMappingException; these are collected into failures/conflicts. After the loop, if any failures occurred, a single TraceConflictedMappingException(\"Conflicting mappings for \" + failures, conflicts) is thrown listing the conflicting ranges.","triggerScenarios":"Calling the bulk identity-mapping helper while pre-existing static mappings already cover (or overlap in lifespan) some of the target ranges, with truncateExisting=false. Re-running a mapping operation without first clearing the prior mappings.","commonSituations":"Re-importing/re-mapping modules over traces that already have mappings from a previous session. Concurrent or repeated mapping commands that overlap. Module map refresh when old mappings were not removed.","solutions":["Pass truncateExisting=true to delete or truncate the lifespan of overlapping existing mappings.","Before bulk mapping, clear the conflicting existing mappings (delete or shrink their lifespan).","Catch TraceConflictedMappingException and use getConflicts() to report/resolve the specific overlapping ranges, then retry with truncation."],"exampleFix":"// before\nDebuggerStaticMappingUtils.addIdentityMappings(from, toProgram, ranges, false);\n// throws: Conflicting mappings for [...]\n\n// after\nDebuggerStaticMappingUtils.addIdentityMappings(from, toProgram, ranges, true); // truncate existing","handlingStrategy":"try-catch","validationCode":"// Before bulk identity mapping, optionally clear/truncate existing overlaps,\n// or decide to pass truncateExisting=true.\nboolean truncate = shouldOverwriteExisting(); // domain decision\nDebuggerStaticMappingUtils.addIdentityMappings(from, toProgram, ranges, truncate);","typeGuard":null,"tryCatchPattern":"try {\n    DebuggerStaticMappingUtils.addIdentityMappings(from, toProgram, ranges, false);\n} catch (TraceConflictedMappingException e) {\n    // e.getConflicts() lists the overlapping mappings\n    DebuggerStaticMappingUtils.addIdentityMappings(from, toProgram, ranges, true); // truncate\n}","preventionTips":["Decide up front whether to truncate existing overlapping mappings.","Clear stale mappings before re-running bulk mapping operations.","Use getConflicts() to report exactly which ranges overlap when truncation is not desired."],"tags":["static-mapping","conflict","lifespan","bulk-ops"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}