{"record":{"id":"5856b5e34d6c9257","repo":"NationalSecurityAgency/ghidra","slug":"attempt-to-create-existing-memory","errorCode":null,"errorMessage":"Attempt to create existing memory","messagePattern":"Attempt to create existing memory","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java","lineNumber":701,"sourceCode":"\t\t}\n\t\tint ilen = (int) length;\n\t\t// NB: Right now, we return a full page even if the method/reftype\n\t\t//   is missing.  Probably should do something saner, e.g. mark it as an error,\n\t\t//   but gets tricky given all the possible callers.\n\t\tbyte[] bytes = new byte[ilen];\n\t\tArrays.fill(bytes, (byte) 0xFF);\n\t\tif (addressSpace.getName().equals(\"ram\")) {\n\t\t\tMethod method = connector.getMethodForAddress(address);\n\t\t\tif (method != null) {\n\t\t\t\tbyte[] bytecodes = method.bytecodes();\n\t\t\t\tif (bytecodes != null) {\n\t\t\t\t\tbytes = Arrays.copyOf(bytecodes, ilen);\n\t\t\t\t}\n\t\t\t\tstate.trace.putBytes(mappedAddress, bytes, state.trace.getSnap());\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (create) {\n\t\t\t\t\tthrow new RuntimeException(\"Attempt to create existing memory\");\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (addressSpace.getName().equals(\"constantPool\")) {\n\t\t\tReferenceType reftype = connector.getReferenceTypeForPoolAddress(address);\n\t\t\tif (reftype != null) {\n\t\t\t\tbyte[] bytecodes = reftype.constantPool();\n\t\t\t\tif (bytecodes != null) {\n\t\t\t\t\tbytes = Arrays.copyOf(bytecodes, ilen);\n\t\t\t\t}\n\t\t\t\tstate.trace.putBytes(mappedAddress, bytes, state.trace.getSnap());\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthrow new RuntimeException();\n\t}\n","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java#L683-L719","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Refresh the connector's method-to-address mapping (re-sync from the target VM) before retrying the memory operation.","Call with create=false if the operation should be a best-effort read rather than a strict create.","Verify the target VM is suspended and its class/method layout is current relative to the address being accessed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling the create path, ensure the address resolves to a method\nMethod m = connector.getMethodForAddress(address);\nif (m == null) {\n    // refresh mapping or pass create=false instead of forcing create=true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the connector's method-to-address mapping fresh by re-syncing after VM resume/class-load events.","Prefer create=false for speculative memory reads.","Treat a null method lookup as a signal to refresh state, not an error to force through."],"tags":["memory","jdi","address-mapping","ghidra-debug"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}