{"record":{"id":"3a3426a8d68eeb5e","repo":"NationalSecurityAgency/ghidra","slug":"cannot-write-to-watch-variable-without-an-address","errorCode":null,"errorMessage":"Cannot write to watch variable without an address","messagePattern":"Cannot write to watch variable without an address","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java","lineNumber":463,"sourceCode":"\t}\n\n\tpublic void setRawValueIntString(String intString) {\n\t\tintString = intString.trim();\n\t\tfinal BigInteger val;\n\t\tif (intString.startsWith(\"0x\")) {\n\t\t\tval = new BigInteger(intString.substring(2), 16);\n\t\t}\n\t\telse {\n\t\t\tval = new BigInteger(intString, 10);\n\t\t}\n\t\tsetRawValueBytes(\n\t\t\tUtils.bigIntegerToBytes(val, value.length, provider.language.isBigEndian()));\n\t}\n\n\tpublic void setRawValueBytes(byte[] bytes) {\n\t\tsynchronized (lock) {\n\t\t\tif (address == null) {\n\t\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"Cannot write to watch variable without an address\");\n\t\t\t}\n\t\t\tif (bytes.length > value.length) {\n\t\t\t\tthrow new IllegalArgumentException(\"Byte arrays cannot exceed length of variable\");\n\t\t\t}\n\t\t\tif (bytes.length < value.length) {\n\t\t\t\tbyte[] fillOld = Arrays.copyOf(value, value.length);\n\t\t\t\tSystem.arraycopy(bytes, 0, fillOld, 0, bytes.length);\n\t\t\t\tbytes = fillOld;\n\t\t\t}\n\t\t\tDebuggerControlService controlService = provider.controlService;\n\t\t\tif (controlService == null) {\n\t\t\t\tthrow new AssertionError(\"No control service\");\n\t\t\t}\n\t\t\tStateEditor editor = controlService.createStateEditor(provider.current);\n\t\t\teditor.setVariable(address, bytes).exceptionally(ex -> {\n\t\t\t\tMsg.showError(this, null, \"Write Failed\",\n\t\t\t\t\t\"Could not modify watch value (on target)\", ex);","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/watch/DefaultWatchRow.java#L445-L481","documentation":"Thrown by DefaultWatchRow.setRawValueBytes when the watch row's address is null. A watch cannot be written until it has been resolved to a concrete address in the current trace/coordinates.","triggerScenarios":"Calling setRawValueBytes while the row's address field is null (the watch expression has not been resolved to a location, or the current coordinates do not map it).","commonSituations":"Editing a watch before the target is running and symbols resolved; watch on a symbol/register not present in the current platform; stale watch row left from a disconnected session.","solutions":["Ensure the debug target/emulator is live and the watch's address is resolved (non-null) before editing.","Call isRawValueEditable() / check address != null before attempting a write.","Re-resolve the watch by switching to valid coordinates or refreshing the target.","Remove and re-add the watch so its address rebinds."],"exampleFix":"// before\nrow.setRawValueBytes(bytes); // throws if address == null\n\n// after\nif (row.getAddress() == null) {\n    Msg.warn(this, \"Watch has no address; cannot write\");\n    return;\n}\nrow.setRawValueBytes(bytes);","handlingStrategy":"validation","validationCode":"boolean writable = row.isRawValueEditable() && row.getAddress() != null;","typeGuard":"static boolean watchHasAddress(DefaultWatchRow r) {\n    return r.getAddress() != null;\n}","tryCatchPattern":"try {\n    row.setRawValueBytes(bytes);\n} catch (IllegalStateException e) {\n    Msg.showWarn(this, null, \"Watch unresolved\", e.getMessage());\n}","preventionTips":["Wait for target live + symbol resolution before editing watches.","Rebind stale watches to valid coordinates."],"tags":["watch","address","unresolved","write"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}