NationalSecurityAgency/ghidra · error · DuplicateNameException
Address space ${name} already exists.
Error message
Address space ${name} already exists. What it means
createOverlayAddressSpace (the public entry point) checks factory.getAddressSpace(name) != null under the write lock and throws DuplicateNameException("Address space name already exists.") if the name is taken. Same invariant as the inner doCreateOverlaySpace check, surfaced one level up. Any address-space name (overlay or base) colliding triggers it.
Source
Thrown at Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/address/DBTraceOverlaySpaceAdapter.java:281
DBTraceOverlaySpaceEntry ent = overlayStore.create();
ProgramOverlayAddressSpace space = factory.addOverlaySpace(ent.getKey(), name, base);
// Only if it succeeds do we store the record
ent.set(space.getName(), base.getName());
trace.updateViewsAddSpaceBlock(space);
trace.setChanged(
new TraceChangeRecord<>(TraceEvents.OVERLAY_ADDED, space, trace, null, space));
return space;
}
public AddressSpace createOverlayAddressSpace(String name, AddressSpace base)
throws DuplicateNameException {
// TODO: Exclusive lock?
try (LockHold hold = LockHold.lock(lock.writeLock())) {
TraceAddressFactory factory = trace.getInternalAddressFactory();
if (factory.getAddressSpace(name) != null) {
throw new DuplicateNameException("Address space " + name + " already exists.");
}
return doCreateOverlaySpace(name, base);
}
}
public AddressSpace getOrCreateOverlayAddressSpace(String name, AddressSpace base) {
// TODO: Exclusive lock?
try (LockHold hold = LockHold.lock(lock.writeLock())) {
TraceAddressFactory factory = trace.getInternalAddressFactory();
AddressSpace space = factory.getAddressSpace(name);
if (space != null) {
return space.getPhysicalSpace() == base ? space : null;
}
try {
return doCreateOverlaySpace(name, base);
}
catch (DuplicateNameException e) {
throw new AssertionError(e);View on GitHub (pinned to d5f144c24d)
Solutions
- Prefer getOrCreateOverlayAddressSpace when you want idempotent behavior.
- Check factory.getAddressSpace(name) == null before creating.
- Catch DuplicateNameException at the call site and prompt for a new name.
Example fix
// before
AddressSpace s = trace.createOverlayAddressSpace(name, base);
// after
AddressSpace s;
if (factory.getAddressSpace(name) != null) {
s = trace.getOrCreateOverlayAddressSpace(name, base);
} else {
s = trace.createOverlayAddressSpace(name, base);
} Defensive patterns
Strategy: validation
Validate before calling
if (factory.getAddressSpace(name) != null) {
return trace.getOrCreateOverlayAddressSpace(name, base);
} Try / catch
try { return trace.createOverlayAddressSpace(name, base); }
catch (DuplicateNameException e) { return trace.getOrCreateOverlayAddressSpace(name, base); } Prevention
- Default to getOrCreate unless you specifically need create-or-fail semantics.
- Surface duplicate-name errors to the UI as a rename prompt, not a crash.
- Reserve built-in space names to avoid accidental collisions.
When it happens
Trigger: Calling createOverlayAddressSpace(name, base) where name already names an address space in the factory; double creation without prior existence check.
Common situations: UI-driven overlay creation where the user reuses an existing name; scripts that assume a fresh trace; names colliding with built-in spaces.
Related errors
- Overlay space '${name}' duplicates name of another address s
- Invalid address space for overlay: {}
- Invalid number of elements specified: {}
- pos cannot be less than zero
- %s: unknown demangling style `%s'
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/f5d601ea638bd86f.
Report an issue: GitHub.