{"record":{"id":"6de0480c4ae034db","repo":"NationalSecurityAgency/ghidra","slug":"failed-to-read-memory","errorCode":null,"errorMessage":"Failed to read memory","messagePattern":"Failed to read memory","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java","lineNumber":89,"sourceCode":"\t\t\tif (!current.isAliveAndReadsPresent()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tAddressSetView selection = getSelection();\n\t\t\tif (selection == null || selection.isEmpty()) {\n\t\t\t\tselection = visible;\n\t\t\t}\n\t\t\tfinal AddressSetView sel = selection;\n\t\t\tTarget target = current.getTarget();\n\n\t\t\tTargetActionTask.executeTask(tool, new Task(NAME, true, true, false) {\n\t\t\t\t@Override\n\t\t\t\tpublic void run(TaskMonitor monitor) throws CancelledException {\n\t\t\t\t\ttarget.invalidateMemoryCaches();\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttarget.readMemoryAsync(sel, monitor).get();\n\t\t\t\t\t}\n\t\t\t\t\tcatch (InterruptedException | ExecutionException e) {\n\t\t\t\t\t\tthrow new RuntimeException(\"Failed to read memory\", e);\n\t\t\t\t\t}\n\t\t\t\t\tmemoryWasRead(sel);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\t@Override\n\t\tpublic boolean isEnabledForContext(ActionContext context) {\n\t\t\treturn current.isAliveAndReadsPresent();\n\t\t}\n\n\t\tpublic void updateEnabled(ActionContext context) {\n\t\t\tsetEnabled(isEnabledForContext(context));\n\t\t}\n\t}\n\n\tprotected class ForReadsTraceListener extends TraceDomainObjectListener {\n\t\tpublic ForReadsTraceListener() {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/action/DebuggerReadsMemoryTrait.java#L71-L107","documentation":"Ghidra DebuggerReadsMemoryTrait wraps the result of target.readMemoryAsync(sel, monitor).get(). If the future completes exceptionally (ExecutionException) or the waiting thread is interrupted (InterruptedException), the task throws RuntimeException(\"Failed to read memory\", e). This typically reflects a backend/target communication failure during a memory-read action.","triggerScenarios":"Invoking the read-memory action on a selection when the debug target's readMemoryAsync fails — e.g., the target process died, the connection dropped, the address range is unreadable, or the task was cancelled/interrupted.","commonSituations":"Target process terminated mid-read; debugger backend connection lost; reading an address range not mapped/accessible; user cancellation racing with the read.","solutions":["Confirm the target is still alive and connected before issuing the read (current.isAliveAndReadsPresent()).","Narrow the selection to known-mapped, accessible memory regions.","Reattach/reconnect to the target if the transport dropped, then retry.","Catch RuntimeException around the action and inspect getCause() to distinguish cancellation from a transport error."],"exampleFix":"// before\ntarget.readMemoryAsync(sel, monitor).get(); // propagates as RuntimeException(\"Failed to read memory\")\n\n// after\ntry {\n    target.readMemoryAsync(sel, monitor).get();\n} catch (ExecutionException ee) {\n    Msg.error(this, \"Target read failed: \" + ee.getCause());\n} catch (InterruptedException ie) {\n    Thread.currentThread().interrupt();\n}","handlingStrategy":"try-catch","validationCode":"if (!current.isAliveAndReadsPresent()) {\n    // target not usable for reads; abort the action\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    target.readMemoryAsync(sel, monitor).get();\n} catch (ExecutionException ee) {\n    Msg.error(this, \"read failed\", ee.getCause());\n} catch (InterruptedException ie) {\n    Thread.currentThread().interrupt();\n}","preventionTips":["Check current.isAliveAndReadsPresent() before issuing reads.","Narrow selections to mapped, accessible ranges.","Inspect getCause() of the wrapped RuntimeException to diagnose transport vs cancellation."],"tags":["ghidra","debugger","java","memory","concurrency"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}