NationalSecurityAgency/ghidra · error · RuntimeException

Attempt to create existing memory

Error message

Attempt to create existing memory

What it means

Thrown in the RAM address-space branch of memory creation: the address did not resolve to a JDI Method (connector.getMethodForAddress returned null) yet the caller passed create=true. This signals a logical conflict — the system was asked to create memory for a region that has no backing method, implying the memory 'already exists' conceptually but cannot be materialized.

Source

Thrown at Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java:701

		}
		int ilen = (int) length;
		// NB: Right now, we return a full page even if the method/reftype
		//   is missing.  Probably should do something saner, e.g. mark it as an error,
		//   but gets tricky given all the possible callers.
		byte[] bytes = new byte[ilen];
		Arrays.fill(bytes, (byte) 0xFF);
		if (addressSpace.getName().equals("ram")) {
			Method method = connector.getMethodForAddress(address);
			if (method != null) {
				byte[] bytecodes = method.bytecodes();
				if (bytecodes != null) {
					bytes = Arrays.copyOf(bytecodes, ilen);
				}
				state.trace.putBytes(mappedAddress, bytes, state.trace.getSnap());
			}
			else {
				if (create) {
					throw new RuntimeException("Attempt to create existing memory");
				}
			}
			return;
		}
		if (addressSpace.getName().equals("constantPool")) {
			ReferenceType reftype = connector.getReferenceTypeForPoolAddress(address);
			if (reftype != null) {
				byte[] bytecodes = reftype.constantPool();
				if (bytecodes != null) {
					bytes = Arrays.copyOf(bytecodes, ilen);
				}
				state.trace.putBytes(mappedAddress, bytes, state.trace.getSnap());
			}
			return;
		}
		throw new RuntimeException();
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Refresh the connector's method-to-address mapping (re-sync from the target VM) before retrying the memory operation.
  2. Call with create=false if the operation should be a best-effort read rather than a strict create.
  3. Verify the target VM is suspended and its class/method layout is current relative to the address being accessed.
Defensive patterns

Strategy: validation

Validate before calling

// Before calling the create path, ensure the address resolves to a method
Method m = connector.getMethodForAddress(address);
if (m == null) {
    // refresh mapping or pass create=false instead of forcing create=true
}

Prevention

When it happens

Trigger: Invoking the memory-save/create path with create=true for an address that the JDI connector cannot map to a Method object (e.g., an address in 'ram' space that corresponds to no loaded method). This happens when the address translation tables are stale or the target VM loaded/unloaded classes since the tables were built.

Common situations: The target JVM hot-swapped or unloaded classes after the address map was built; the trace is being populated for an address range beyond any method; a stale connector state after the VM resumed and code moved.

Related errors


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