{"record":{"id":"c7d8728cb973aab6","repo":"NationalSecurityAgency/ghidra","slug":"addressrange-requires-a-trace-for-context","errorCode":null,"errorMessage":"AddressRange requires a trace for context","messagePattern":"AddressRange requires a trace for context","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/tracermi/ValueDecoder.java","lineNumber":86,"sourceCode":"\t\tpublic Object toValue(Value value) {\n\t\t\tObject obj = ValueDecoder.super.toValue(value);\n\t\t\tif (obj instanceof byte[] va) {\n\t\t\t\treturn NumericUtilities.convertBytesToString(va, \":\");\n\t\t\t}\n\t\t\treturn obj;\n\t\t}\n\t};\n\n\tdefault Address toAddress(Addr addr, boolean required) {\n\t\tif (required) {\n\t\t\tthrow new IllegalStateException(\"Address requires a trace for context\");\n\t\t}\n\t\treturn null;\n\t}\n\n\tdefault AddressRange toRange(AddrRange range, boolean required) {\n\t\tif (required) {\n\t\t\tthrow new IllegalStateException(\"AddressRange requires a trace for context\");\n\t\t}\n\t\treturn null;\n\t}\n\n\tdefault Object getObject(ObjSpec spec, boolean required) {\n\t\tif (required) {\n\t\t\tthrow new IllegalStateException(\"TraceObject requires a trace for context\");\n\t\t}\n\t\treturn null;\n\t}\n\n\tdefault Object getObject(ObjDesc desc, boolean required) {\n\t\tif (required) {\n\t\t\tthrow new IllegalStateException(\"TraceObject requires a trace for context\");\n\t\t}\n\t\treturn null;\n\t}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-rmi-trace/src/main/java/ghidra/app/plugin/core/debug/service/tracermi/ValueDecoder.java#L68-L104","documentation":"Thrown by the default ValueDecoder.toRange when required is true. The default decoder lacks a Trace, so it cannot resolve an AddrRange's address space into a real AddressSpace and cannot build an AddressRange. Only a trace-bound decoder (OpenTrace) can resolve the space and clamp/validate the range.","triggerScenarios":"Calling toRange(range, true) on ValueDecoder.DEFAULT or any decoder without trace context, when a value requires an AddressRange.","commonSituations":"Decoding ranges in a trace-less context (display formatting of a message that unexpectedly needs a real range); using the wrong decoder for a value that is a range.","solutions":["Use the OpenTrace decoder when you need to resolve ranges, so toRange has the trace's address spaces.","Call toRange(range, false) if a range is optional, yielding null instead of an exception.","Note ValueDecoder.DISPLAY overrides toRange to synthesize a generic 64-bit space, so use DISPLAY for display-only decoding."],"exampleFix":"// before\nValueDecoder dec = ValueDecoder.DEFAULT;\nAddressRange r = dec.toRange(range, true);\n\n// after\nValueDecoder dec = openTrace; // trace-bound\nAddressRange r = dec.toRange(range, true);","handlingStrategy":"validation","validationCode":"ValueDecoder dec = (openTrace != null) ? openTrace : ValueDecoder.DEFAULT;\nAddressRange r = (openTrace != null) ? dec.toRange(range, true) : null;","typeGuard":"boolean hasTraceContext(ValueDecoder dec) {\n    return dec instanceof OpenTrace;\n}","tryCatchPattern":"try {\n    return dec.toRange(range, true);\n} catch (IllegalStateException e) {\n    return null;\n}","preventionTips":["Use OpenTrace (or DISPLAY for display-only) as the decoder when resolving ranges.","Pass required=false for optional ranges.","Do not use ValueDecoder.DEFAULT for range-bearing values."],"tags":["value-decoder","address-range","trace-context","trace-rmi"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}