{"record":{"id":"bb62aaf4cfadaaf8","repo":"NationalSecurityAgency/ghidra","slug":"trace-is-not-from-this-connection","errorCode":null,"errorMessage":"Trace is not from this connection","messagePattern":"Trace is not from this connection","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/tracermi/RecordRemoteParameter.java","lineNumber":30,"sourceCode":" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage ghidra.app.plugin.core.debug.service.tracermi;\n\nimport ghidra.debug.api.tracermi.RemoteParameter;\nimport ghidra.program.model.address.AddressOverflowException;\nimport ghidra.trace.model.Trace;\nimport ghidra.trace.model.target.schema.TraceObjectSchema.SchemaName;\n\npublic record RecordRemoteParameter(TraceRmiHandler handler, String name, SchemaName type,\n\t\tboolean required, ValueSupplier defaultValue, String display, String description)\n\t\timplements RemoteParameter {\n\n\tpublic Object getDefaultValue(Trace trace) {\n\t\tOpenTrace open = handler.getOpenTrace(trace);\n\t\tif (open == null) {\n\t\t\tthrow new IllegalArgumentException(\"Trace is not from this connection\");\n\t\t}\n\t\ttry {\n\t\t\treturn defaultValue().get(open);\n\t\t}\n\t\tcatch (AddressOverflowException e) {\n\t\t\tthrow new AssertionError(e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Object getDefaultValue() {\n\t\ttry {\n\t\t\treturn defaultValue().get(ValueDecoder.DEFAULT);\n\t\t}\n\t\tcatch (AddressOverflowException e) {\n\t\t\tthrow new AssertionError(e);\n\t\t}\n\t}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/tracermi/RecordRemoteParameter.java#L12-L48","documentation":"Thrown by RecordRemoteParameter.getDefaultValue(Trace) when the supplied Trace object is not one of the traces opened by this TraceRmiHandler connection. The handler keeps a registry (openTraces) of traces it created; getOpenTrace(trace) returns null for any trace opened on a different handler, so the parameter's default value cannot be computed in that trace's context.","triggerScenarios":"Calling RemoteParameter.getDefaultValue(someTrace) where someTrace was created by a different TraceRmi connection, or by Ghidra directly rather than via the TraceRmi handler. Also occurs when passing a Trace from one connection into a method/parameter object that belongs to another.","commonSituations":"Reusing a Trace object across two debugger sessions/connections; mixing traces opened manually (DBTrace) with those opened via TraceRmi; stale Trace reference held after the connection that created it was disposed.","solutions":["Pass a Trace that was created/opened through the same TraceRmiHandler (via createTrace/openTrace) whose RemoteMethod/RemoteParameter you are querying.","If you hold multiple connections, look up the correct handler for the trace before calling getDefaultValue, or use the no-arg getDefaultValue() which does not need a trace.","When a connection is disposed, discard all Trace references obtained from it; do not feed them into another handler's parameters."],"exampleFix":"// before\nObject def = param.getDefaultValue(traceFromOtherConnection);\n\n// after\nif (handler.getOpenTrace(trace) == null) {\n    // use the trace-less default, or re-open via this handler\n    Object def = param.getDefaultValue();\n} else {\n    Object def = param.getDefaultValue(trace);\n}","handlingStrategy":"validation","validationCode":"OpenTrace open = handler.getOpenTrace(trace);\nif (open == null) {\n    Object def = param.getDefaultValue(); // trace-less default\n} else {\n    Object def = param.getDefaultValue(trace);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return param.getDefaultValue(trace);\n} catch (IllegalArgumentException e) {\n    // trace not from this connection; fall back to trace-less default\n    return param.getDefaultValue();\n}","preventionTips":["Only pass Trace objects created by the same TraceRmiHandler whose parameter you query.","Discard Trace references when their owning connection is disposed.","Use the no-arg getDefaultValue() when you do not have a trace-bound context."],"tags":["trace-rmi","connection","remote-parameter","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}