{"record":{"id":"8be0d9114a739095","repo":"NationalSecurityAgency/ghidra","slug":"must-fetch","errorCode":null,"errorMessage":"Must fetch ","messagePattern":"Must fetch ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/util/TraceRegisterUtils.java","lineNumber":247,"sourceCode":"\t\t\treturn new RegisterValue(register, value);\n\t\t}\n\t\tAddress addr = data.getTrace().getBaseAddressFactory().getAddress(representation);\n\t\tif (addr == null) {\n\t\t\tthrow new DataTypeEncodeException(\"Invalid address\", representation, dataType);\n\t\t}\n\t\treturn new RegisterValue(register, addr.getOffsetAsBigInteger());\n\t}\n\n\tpublic static RegisterValue combineWithTraceParentRegisterValue(Register parent,\n\t\t\tRegisterValue rv, TracePlatform platform, long snap, TraceMemorySpace regs,\n\t\t\tboolean requireKnown) {\n\t\tRegister reg = rv.getRegister();\n\t\tif (reg == parent) {\n\t\t\treturn rv;\n\t\t}\n\t\tif (regs == null) {\n\t\t\tif (requireKnown) {\n\t\t\t\tthrow new IllegalStateException(\"Must fetch \" + parent + \" before setting \" + reg);\n\t\t\t}\n\t\t\treturn rv.getRegisterValue(parent);\n\t\t}\n\t\tif (requireKnown) {\n\t\t\tif (TraceMemoryState.KNOWN != regs.getState(platform, snap, parent)) {\n\t\t\t\tthrow new IllegalStateException(\"Must fetch \" + parent + \" before setting \" + reg);\n\t\t\t}\n\t\t}\n\t\treturn regs.getValue(platform, snap, parent).combineValues(rv);\n\t}\n\n\tpublic static RegisterValue combineWithTraceBaseRegisterValue(RegisterValue rv,\n\t\t\tTracePlatform platform, long snap, TraceMemorySpace regs, boolean requireKnown) {\n\t\treturn combineWithTraceParentRegisterValue(rv.getRegister().getBaseRegister(), rv, platform,\n\t\t\tsnap, regs, requireKnown);\n\t}\n\n\tpublic static ByteBuffer prepareBuffer(Register register) {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/util/TraceRegisterUtils.java#L229-L265","documentation":"TraceRegisterUtils.combineWithTraceParentRegisterValue needs the parent register's value from the trace's memory space. When regs (TraceMemorySpace) is null and requireKnown is true, there is no register space to read the parent value from, so the combination cannot proceed safely. The method requires the parent's current value to be available before setting a sub-register.","triggerScenarios":"Calling combineWithTraceParentRegisterValue where the TraceMemorySpace regs parameter is null and requireKnown=true. This happens when the caller has no register space handle (e.g. operating on a platform/frame without a memory space) but asks for known-state combination.","commonSituations":"Setting a sub-register (e.g. AL within EAX) before the trace has a register space for that thread/frame. Operating on a snapshot or thread where register memory space was never created. Using requireKnown=true in a context where the trace is still being set up and register state hasn't been initialized.","solutions":["Pass requireKnown=false if you don't need the parent value to be in KNOWN state","Ensure the TraceMemorySpace for the thread/frame exists: obtain it via trace.getMemoryManager().getMemorySpace(threadKey, true) before calling","Fetch/set the parent register first to create the register space state","If no register space is available, use rv.getRegisterValue(parent) with requireKnown=false"],"exampleFix":"// before\nRegisterValue combined = TraceRegisterUtils.combineWithTraceParentRegisterValue(\n    parent, rv, platform, snap, null, true); // regs is null\n// after\nTraceMemorySpace regs = trace.getMemoryManager()\n    .getRegisterSpace(threadKey, frameLevel, true);\nRegisterValue combined = TraceRegisterUtils.combineWithTraceParentRegisterValue(\n    parent, rv, platform, snap, regs, true);","handlingStrategy":"validation","validationCode":"boolean canCombineWithParent(TraceMemorySpace regs, boolean requireKnown) {\n    if (requireKnown && regs == null) return false;\n    return true;\n}","typeGuard":"// N/A","tryCatchPattern":"// IllegalStateException; validate preconditions before calling","preventionTips":["Ensure TraceMemorySpace is non-null before requiring known state","Obtain the register space with getRegisterSpace(threadKey, frameLevel, true) before combining","Pass requireKnown=false when the parent state is not guaranteed"],"tags":["ghidra","trace-utils","register","memory-state","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}