NationalSecurityAgency/ghidra · error · DuplicateNameException

Couldn't create symbol '" + mySym.getName(true) + "'.

Error message

Couldn't create symbol '" + mySym.getName(true) + "'.

What it means

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.

Source

Thrown at Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java:1370

			}
		}

		String newName = name;
		for (int i = 1; i < Integer.MAX_VALUE; i++) {
			try {
				resultSym = createSymbol(newName, myType, resultAddr, resultNamespace, myPgm, id,
					mySym.getSource());
				if (resultSym != null && i > 1) {
					renamedConflictIDs.add(resultSym.getID());
				}
				return;
			}
			catch (DuplicateNameException e) {
				// try again
			}
			newName = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + i;
		}
		throw new DuplicateNameException("Couldn't create symbol '" + mySym.getName(true) + "'.");
	}

//	private void processAddedSymbolComment(Symbol resultSym, Symbol mySym) {
//		// My version added a symbol that matches on in the result version.
//		String resultComment = resultSym.getSymbolStringData();
//		String myComment = mySym.getSymbolStringData();
//		if (SystemUtilities.isEqual(resultComment, myComment)) {
//			return; // Already has My symbol comment.
//		}
//		if (myComment == null) {
//			return; // My version isn't setting a symbol comment.
//		}
//		if (resultComment == null) {
//			resultSym.setSymbolStringData(myComment); // Latest didn't set a comment, but My did so use My symbol comment.
//		}
//		else if (!myComment.equals(resultComment)) {
//			saveAddCommentConflict(mySym.getID()); // Both set a different symbol comment, so conflict
//		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Increase the retry bound / use a UUID-based suffix to guarantee uniqueness when collisions are dense.
  2. Pre-clean conflicting symbols in the result program before merge.
  3. Catch DuplicateNameException and re-run the symbol create with a programmatically unique name (e.g. address + id).
  4. Verify the target namespace/address combination is not already saturated.

Example fix

// before
for (int i = 1; i <= MAX; i++) {
    newName = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + i;
    resultSym = createSymbol(newName, ...);
}
throw new DuplicateNameException("Couldn't create symbol '" + mySym.getName(true) + "'.");

// after — guaranteed-unique fallback name
String base = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX;
String newName = base + mySym.getID(); // unique by symbol id
resultSym = createSymbol(newName, myType, resultAddr, resultNamespace, myPgm, id, mySym.getSource());
Defensive patterns

Strategy: fallback

Validate before calling

// probe for a free suffixed name before relying on the retry loop
String candidate = name + ProgramMerge.SYMBOL_CONFLICT_SUFFIX + mySym.getID();
if (resultSymTab.getSymbol(candidate, resultAddr, resultNamespace) == null) {
    // safe to create
}

Type guard

boolean nameFree = resultSymTab.getSymbol(candidate, resultAddr, resultNamespace) == null;

Try / catch

try {
    createSymbolWithRetry(...);
} catch (DuplicateNameException e) {
    // fall back to a globally unique name
    createSymbol(name + "@" + mySym.getID(), myType, resultAddr, resultNamespace, myPgm, id, src);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/7f27d0b7d84bdb30. Report an issue: GitHub.