{"record":{"id":"7f27d0b7d84bdb30","repo":"NationalSecurityAgency/ghidra","slug":"couldn-t-create-symbol-mysym-getname-true","errorCode":null,"errorMessage":"Couldn't create symbol '\" + mySym.getName(true) + \"'.","messagePattern":"Couldn't create symbol '\" \\+ mySym\\.getName\\(true\\) \\+ \"'\\.","errorType":"exception","errorClass":"DuplicateNameException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java","lineNumber":1370,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tString newName = name;\n\t\tfor (int i = 1; i < Integer.MAX_VALUE; i++) {\n\t\t\ttry {\n\t\t\t\tresultSym = createSymbol(newName, myType, resultAddr, resultNamespace, myPgm, id,\n\t\t\t\t\tmySym.getSource());\n\t\t\t\tif (resultSym != null && i > 1) {\n\t\t\t\t\trenamedConflictIDs.add(resultSym.getID());\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (DuplicateNameException e) {\n\t\t\t\t// try again\n\t\t\t}\n\t\t\tnewName = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + i;\n\t\t}\n\t\tthrow new DuplicateNameException(\"Couldn't create symbol '\" + mySym.getName(true) + \"'.\");\n\t}\n\n//\tprivate void processAddedSymbolComment(Symbol resultSym, Symbol mySym) {\n//\t\t// My version added a symbol that matches on in the result version.\n//\t\tString resultComment = resultSym.getSymbolStringData();\n//\t\tString myComment = mySym.getSymbolStringData();\n//\t\tif (SystemUtilities.isEqual(resultComment, myComment)) {\n//\t\t\treturn; // Already has My symbol comment.\n//\t\t}\n//\t\tif (myComment == null) {\n//\t\t\treturn; // My version isn't setting a symbol comment.\n//\t\t}\n//\t\tif (resultComment == null) {\n//\t\t\tresultSym.setSymbolStringData(myComment); // Latest didn't set a comment, but My did so use My symbol comment.\n//\t\t}\n//\t\telse if (!myComment.equals(resultComment)) {\n//\t\t\tsaveAddCommentConflict(mySym.getID()); // Both set a different symbol comment, so conflict\n//\t\t}","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java#L1352-L1388","documentation":"Thrown as DuplicateNameException by SymbolMerger after exhausting a retry loop that attempted to create a symbol with successive conflict-suffix names (name + SYMBOL_CONFLICT_SUFFIX + i). Each attempt that hit DuplicateNameException was swallowed and retried; reaching the throw means no suffixed name was available either, so the symbol could not be placed in the result program.","triggerScenarios":"Calling the symbol-create helper with a name whose base and all numbered conflict-suffix variants already exist at the same address/namespace/scope in the result program; the loop counter i exceeded its bound without a free name.","commonSituations":"Repeated merges accumulating many SYMBOL_CONFLICT_SUFFIX variants until the search space is exhausted; merging into a program already dense with symbols at one address; a very small or fixed retry bound hit due to many collisions.","solutions":["Increase the retry bound / use a UUID-based suffix to guarantee uniqueness when collisions are dense.","Pre-clean conflicting symbols in the result program before merge.","Catch DuplicateNameException and re-run the symbol create with a programmatically unique name (e.g. address + id).","Verify the target namespace/address combination is not already saturated."],"exampleFix":"// before\nfor (int i = 1; i <= MAX; i++) {\n    newName = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + i;\n    resultSym = createSymbol(newName, ...);\n}\nthrow new DuplicateNameException(\"Couldn't create symbol '\" + mySym.getName(true) + \"'.\");\n\n// after — guaranteed-unique fallback name\nString base = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX;\nString newName = base + mySym.getID(); // unique by symbol id\nresultSym = createSymbol(newName, myType, resultAddr, resultNamespace, myPgm, id, mySym.getSource());","handlingStrategy":"fallback","validationCode":"// probe for a free suffixed name before relying on the retry loop\nString candidate = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + mySym.getID();\nif (resultSymTab.getSymbol(candidate, resultAddr, resultNamespace) == null) {\n    // safe to create\n}","typeGuard":"boolean nameFree = resultSymTab.getSymbol(candidate, resultAddr, resultNamespace) == null;","tryCatchPattern":"try {\n    createSymbolWithRetry(...);\n} catch (DuplicateNameException e) {\n    // fall back to a globally unique name\n    createSymbol(name + \"@\" + mySym.getID(), myType, resultAddr, resultNamespace, myPgm, id, src);\n}","preventionTips":["Use a uniqueness guaranteeing suffix (symbol ID / UUID) instead of a small numeric loop.","Pre-clean dense symbol collisions at the target address.","Increase the retry bound for high-collision merges."],"tags":["ghidra","merge","symbol","duplicate-name"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}