{"record":{"id":"83d2d0f9b6d77fa3","repo":"NationalSecurityAgency/ghidra","slug":"another-mapping-would-conflict","errorCode":null,"errorMessage":"Another mapping would conflict","messagePattern":"Another mapping would conflict","errorType":"exception","errorClass":"TraceConflictedMappingException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/module/DBTraceStaticMappingManager.java","lineNumber":90,"sourceCode":"\t\tmappingStore.invalidateCache();\n\t}\n\n\t@Override\n\tpublic void dbError(IOException e) {\n\t\ttrace.dbError(e);\n\t}\n\n\t@Override\n\tpublic DBTraceStaticMapping add(AddressRange range, Lifespan lifespan, URL toProgramURL,\n\t\t\tString toAddress) throws TraceConflictedMappingException {\n\t\tObjects.requireNonNull(toProgramURL,\n\t\t\t\"Program URL cannot be null. Program must be in a project to have a URL.\");\n\t\ttry (LockHold hold = LockHold.lock(lock.writeLock())) {\n\t\t\tDBTraceStaticMapping conflict =\n\t\t\t\tfindAnyConflicting(range, lifespan, toProgramURL, toAddress);\n\t\t\tif (conflict != null) {\n\t\t\t\t// TODO: Find all conflicts?\n\t\t\t\tthrow new TraceConflictedMappingException(\"Another mapping would conflict\",\n\t\t\t\t\tSet.of(conflict));\n\t\t\t}\n\t\t\t// TODO: A more sophisticated coverage check?\n\t\t\t// TODO: Better coalescing\n\t\t\t// For now, just check if a single entry contains the would-be-new entry\n\t\t\tfor (DBTraceStaticMapping covers : findAllOverlapping(range, lifespan)) {\n\t\t\t\tif (!covers.getTraceAddressRange().contains(range.getMinAddress())) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!covers.getTraceAddressRange().contains(range.getMaxAddress())) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!covers.getLifespan().encloses(lifespan)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn covers;\n\t\t\t}\n\t\t\tDBTraceStaticMapping mapping = mappingStore.create();","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/module/DBTraceStaticMappingManager.java#L72-L108","documentation":"Thrown as TraceConflictedMappingException by DBTraceStaticMappingManager.add when a newly added static mapping would overlap an existing mapping (same trace address range and overlapping lifespan) that points to a different static program or address. Trace mappings are required to be consistent: the same dynamic location over a given snap range cannot map to two different static locations.","triggerScenarios":"Calling add(range, lifespan, toProgramURL, toAddress) where findAnyConflicting detects an existing mapping over the same range+snap that maps to a different program URL or static address.","commonSituations":"Re-mapping a trace region to a different program after it was already mapped. Overlapping two module static mappings that disagree. Re-running an auto-mapping/import step without first clearing the old conflicting mapping. Loading a trace that already has mappings then adding new ones over the same addresses.","solutions":["Before adding, call findAnyConflicting (or query existing overlapping mappings) and remove or narrow the conflicting mapping first.","Use a non-overlapping lifespan or address range so the new mapping does not collide with the existing one.","If the new mapping is correct, delete the old conflicting mapping via its delete() method, then retry add()."],"exampleFix":"// before\nmappingManager.add(range, lifespan, programURL, staticAddr); // throws if conflict\n\n// after\nDBTraceStaticMapping conflict = mappingManager.findAnyConflicting(range, lifespan, programURL, staticAddr);\nif (conflict != null) {\n    conflict.delete();\n}\nmappingManager.add(range, lifespan, programURL, staticAddr);","handlingStrategy":"try-catch","validationCode":"// Check for conflicts before adding a mapping\nDBTraceStaticMapping conflict =\n    mappingManager.findAnyConflicting(range, lifespan, programURL, staticAddr);\nif (conflict != null) {\n    conflict.delete(); // remove or narrow the old mapping\n}","typeGuard":null,"tryCatchPattern":"try {\n    mappingManager.add(range, lifespan, programURL, staticAddr);\n} catch (TraceConflictedMappingException e) {\n    // e.getConflicts() returns the conflicting mapping set\n    for (DBTraceStaticMapping c : e.getConflicts()) {\n        // decide: delete, narrow lifespan, or skip\n    }\n}","preventionTips":["Query findAnyConflicting before adding a mapping in overlapped regions.","Clear or narrow old mappings before re-mapping the same range/snap.","Design mapping workflows to be idempotent so re-runs do not stack conflicting mappings."],"tags":["trace-modeling","mapping","conflict","lifespan","ghidra"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}