NationalSecurityAgency/ghidra · error · DuplicateNameException

Couldn't create namespace '" + name + "' in namespace '" + r

Error message

Couldn't create namespace '" + name + "' in namespace '" + resultParentNs.getName(true) + "'.

What it means

Thrown as DuplicateNameException by SymbolMerger when it cannot establish a namespace under resultParentNs — the lookup for an existing unique symbol of that name found nothing usable and the create path fell through to the trailing throw. It signals an unresolved namespace-name conflict during symbol/namespace merge where neither reuse nor rename succeeded.

Source

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

				}
				// Found the equivalent namespace so return it.
				return ns;
			}
			// Create it, since nothing with this conflict name.
			Symbol uniqueSymbol = createSymbol(uniqueSymbolName, st, resultAddr, resultParentNs,
				srcPgm, srcSymID, source);
			if (uniqueSymbol != null) {
				Object obj = uniqueSymbol.getObject();
				if (obj instanceof Namespace) {
					if (!uniqueSymbolName.equals(name)) {
						renamedConflictIDs.add(uniqueSymbol.getID());
					}
					return (Namespace) obj;
				}
			}
			break; // Otherwise throw exception
		}
		throw new DuplicateNameException("Couldn't create namespace '" + name + "' in namespace '" +
			resultParentNs.getName(true) + "'.");
	}

	/**
	 * Determine the type of changes to the symbols in the LATEST and MY (CheckedOut) program.
	 * Changes can be symbol removed, added, changed, renamed, and set to primary.
	 * @param monitor task monitor for displaying progress to the user
	 * @throws CancelledException if the user cancels the merge.
	 */
	private void setupSymbolChanges(TaskMonitor monitor) throws CancelledException {

		long[] tempMyAddIDs = listingMergeMgr.myChanges.getSymbolAdditions();
		long[] tempMyChangeIDs = listingMergeMgr.myChanges.getSymbolChanges();
		long[] tempLatestAddIDs = listingMergeMgr.latestChanges.getSymbolAdditions();
		long[] tempLatestChangeIDs = listingMergeMgr.latestChanges.getSymbolChanges();

		int max = tempMyAddIDs.length + tempMyChangeIDs.length + tempLatestAddIDs.length +
			tempLatestChangeIDs.length + 5;

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Resolve the namespace-name conflict manually in the merge GUI before re-running, or choose the 'Use For All' option.
  2. Pre-merge: rename one side's conflicting namespace so the names differ before merge.
  3. Catch DuplicateNameException in automated merge tooling and surface it as a manual-conflict item rather than aborting.
  4. Inspect resultParentNs to confirm it exists and is writable in the result program.

Example fix

// before
// merger.createNamespace(...) falls through to:
throw new DuplicateNameException("Couldn't create namespace '" + name + "' in namespace '" + resultParentNs.getName(true) + "'.");

// after — caller handles the conflict explicitly
try {
    Namespace ns = merger.resolveOrCreateNamespace(resultParentNs, name);
} catch (DuplicateNameException e) {
    conflictQueue.add(new NamespaceConflict(resultParentNs, name));
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before merging, check whether the namespace already exists as a Namespace
SymbolTable st = resultPgm.getSymbolTable();
Symbol existing = st.getSymbol(name, resultParentNs);
if (existing == null || !(existing.getObject() instanceof Namespace)) {
    // rename or create to avoid the fall-through throw
}

Type guard

boolean canCreateNs = resultParentNs != null && (st.getSymbol(name, resultParentNs) == null || st.getSymbol(name, resultParentNs).getObject() instanceof Namespace);

Try / catch

try {
    Namespace ns = merger.resolveOrCreateNamespace(resultParentNs, name);
} catch (DuplicateNameException e) {
    conflictQueue.add(new NamespaceConflict(resultParentNs, name));
}

Prevention

When it happens

Trigger: Merging symbols/namespaces where a namespace of the same name exists in the result program but is not a Namespace-typed symbol (uniqueSymbol.getObject() is not a Namespace), or where the unique-symbol lookup returned null and the create attempt was abandoned at the break.

Common situations: Both checked-out versions added or renamed a namespace identically; a class/namespace collision between the latest and my versions that the merger cannot auto-resolve; a corrupt symbol table where the expected namespace symbol is missing.

Related errors


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