{"record":{"id":"114dba6127da5db7","repo":"NationalSecurityAgency/ghidra","slug":"cannot-compute-stack-address-for-offset-d-nframe","errorCode":null,"errorMessage":"Cannot compute stack address for offset %d.\\nFrame error: %s","messagePattern":"Cannot compute stack address for offset (.+?)\\.\\\\nFrame error: (.+?)","errorType":"exception","errorClass":"UnwindException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/AnalysisUnwoundFrame.java","lineNumber":138,"sourceCode":"\t * proceeds the same as the starting frame.\n\t * \n\t * @param monitor a monitor for cancellation\n\t * @return the next frame up\n\t * @throws CancelledException if the monitor is cancelled\n\t * @throws UnwindException if unwinding fails\n\t */\n\tpublic AnalysisUnwoundFrame<WatchValue> unwindNext(TaskMonitor monitor)\n\t\t\tthrows CancelledException {\n\t\tif (info == null || info.ofReturn() == null) {\n\t\t\tthrow new NoSuchElementException();\n\t\t}\n\t\treturn unwinder.getFrame(coordinates, state, level + 1, null, monitor);\n\t}\n\n\t@Override\n\tprotected Address applyBase(long offset) {\n\t\tif (base == null) {\n\t\t\tthrow new UnwindException(\"Cannot compute stack address for offset %d.\\nFrame error: %s\"\n\t\t\t\t\t.formatted(offset, info.error().getMessage()),\n\t\t\t\tinfo.error());\n\t\t}\n\t\treturn base.add(offset);\n\t}\n\n\t@Override\n\tprotected SavedRegisterMap computeRegisterMap() {\n\t\treturn registerMap;\n\t}\n\n\t@Override\n\tprotected Address computeAddressOfReturnAddress() {\n\t\treturn info.ofReturn(base);\n\t}\n\n\t@Override\n\tpublic Address getReturnAddress() {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/AnalysisUnwoundFrame.java#L120-L156","documentation":"AnalysisUnwoundFrame.applyBase() computes a stack address from an offset by adding it to the frame's base. When base == null the frame's stack base could not be determined (the analysis recorded an error in info.error()), so applyBase throws UnwindException(\"Cannot compute stack address for offset %d.\\nFrame error: %s\") chaining the original analysis error. This propagates during variable/storage evaluation that needs a stack base.","triggerScenarios":"Unwinding a frame whose stack-pointer/base analysis failed (e.g. could not recover SP, missing or unreliable saved registers). Evaluating variables relative to a base that was never computed. Deeper frames past a frame that failed analysis.","commonSituations":"Stripped or optimized binaries where SP recovery is unreliable. Frames where the unwinder could not find a return address or stack-adjustment info. Corrupt or incomplete decompilation/stack annotations.","solutions":["Inspect the chained cause (info.error()) to fix the underlying analysis problem (e.g. recover SP, provide annotations).","Catch UnwindException around frame/variable evaluation and skip the frame that lacks a base.","Improve symbol/annotation data so the unwinder can compute the base (re-analyze, fix function signatures).","Stop unwinding at the frame where analysis failed rather than descending further."],"exampleFix":"// before\nAddress sa = frame.applyBase(offset); // throws UnwindException: base==null\n\n// after\ntry {\n    Address sa = frame.applyBase(offset);\n} catch (UnwindException e) {\n    Msg.warn(this, \"Stack base unavailable for frame; skipping: \" + e.getCause());\n    return null;\n}","handlingStrategy":"try-catch","validationCode":"// No purely local check; base==null stems from failed analysis. Best pre-check:\n// confirm analysis produced a base before evaluating variables relative to it.\nif (frame.getBase() == null) { // if a getter exists\n    // do not call applyBase; skip frame or re-analyze\n}","typeGuard":null,"tryCatchPattern":"try {\n    Address sa = frame.applyBase(offset);\n} catch (UnwindException e) {\n    // e.getCause() is the original analysis error (info.error())\n    // skip this frame or fix the underlying analysis\n}","preventionTips":["Stop unwinding at frames whose analysis failed rather than descending further.","Improve function signatures/annotations so SP/base can be recovered.","Inspect the chained cause to address the real analysis failure."],"tags":["stack-unwinding","analysis","stack-base","decompilation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}