{"record":{"id":"3d7e34380a7fedcc","repo":"NationalSecurityAgency/ghidra","slug":"the-program-counter-reference-is-missing-for-the-f","errorCode":null,"errorMessage":"The program counter reference is missing for the frame!","messagePattern":"The program counter reference is missing for the frame!","errorType":"exception","errorClass":"UnwindException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/ListingUnwoundFrame.java","lineNumber":184,"sourceCode":"\tprivate int loadLevel() {\n\t\tInteger l = getLevel(frame);\n\t\tif (l == null) {\n\t\t\tthrow new IllegalStateException(\"Frame has no comment indicating its level\");\n\t\t}\n\t\treturn l;\n\t}\n\n\tprivate Address loadProgramCounter() {\n\t\tfor (Reference ref : frame.getReferenceIteratorTo()) {\n\t\t\tif (ref.getReferenceType() != RefType.DATA) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ref.getOperandIndex() != StackUnwinder.PC_OP_INDEX) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn ref.getFromAddress();\n\t\t}\n\t\tthrow new UnwindException(\"The program counter reference is missing for the frame!\");\n\t}\n\n\tprivate Address mapProgramCounter() {\n\t\tProgramLocation location = mappingService.getOpenMappedLocation(\n\t\t\tnew DefaultTraceLocation(trace, null, Lifespan.at(snap), pcVal));\n\t\tif (location.getProgram() != function.getProgram()) {\n\t\t\treturn null;\n\t\t}\n\t\treturn location.getByteAddress();\n\t}\n\n\tprivate Function loadFunction() {\n\t\tProgramLocation staticLoc =\n\t\t\tmappingService.getOpenMappedLocation(new DefaultTraceLocation(frame.getTrace(), null,\n\t\t\t\tLifespan.at(coordinates.getSnap()), pcVal));\n\t\tif (staticLoc == null) {\n\t\t\tthrow new UnwindException(\n\t\t\t\t\"The program containing the frame's function is unavailable,\" +","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/ListingUnwoundFrame.java#L166-L202","documentation":"ListingUnwoundFrame.loadProgramCounter() scans references TO the frame's address looking for a DATA reference at operand index StackUnwinder.PC_OP_INDEX, which records the program counter. If no such reference is found, the frame annotation is incomplete and it throws UnwindException(\"The program counter reference is missing for the frame!\"). The PC reference is the anchor that lets the listing-based unwinder locate the frame in static space.","triggerScenarios":"Loading a stack frame annotation that was created without (or stripped of) its PC operand reference. Manually constructed/corrupt frame bookmarks that lack the DATA ref at PC_OP_INDEX. Frames whose PC reference was deleted by the user or another plugin.","commonSituations":"Older or hand-edited frame annotations missing the PC reference. Plugins/tools that create frame annotations incompletely. Reference cleanup operations that removed the PC DATA ref.","solutions":["Ensure frame annotations are created through the stack unwinder so the PC reference (DATA ref at PC_OP_INDEX) is written.","Re-create/re-annotate the frame so the PC reference is restored.","Catch UnwindException and skip the malformed frame, reporting it for repair."],"exampleFix":"// before\nAddress pc = frame.loadProgramCounter(); // throws: PC reference missing\n\n// after\ntry {\n    Address pc = frame.loadProgramCounter();\n} catch (UnwindException e) {\n    Msg.warn(this, \"Frame lacks PC reference; re-annotate the stack frame\");\n    return null;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check that the frame annotation has the PC DATA reference\nboolean hasPc = false;\nfor (Reference ref : frame.getReferenceIteratorTo()) {\n    if (ref.getReferenceType() == RefType.DATA\n            && ref.getOperandIndex() == StackUnwinder.PC_OP_INDEX) {\n        hasPc = true; break;\n    }\n}\nif (!hasPc) {\n    // re-annotate the frame via the stack unwinder before loading\n}","typeGuard":"public static boolean frameHasPcReference(ghidra.program.model.listing.CodeUnit frame) {\n    for (Reference ref : frame.getReferenceIteratorTo()) {\n        if (ref.getReferenceType() == RefType.DATA\n                && ref.getOperandIndex() == StackUnwinder.PC_OP_INDEX) {\n            return true;\n        }\n    }\n    return false;\n}","tryCatchPattern":"try {\n    Address pc = frame.loadProgramCounter();\n} catch (UnwindException e) {\n    if (e.getMessage().contains(\"program counter reference is missing\")) {\n        // re-create the frame annotation via the stack unwinder, then retry\n    } else throw e;\n}","preventionTips":["Create stack frame annotations only through the stack unwinder so the PC DATA ref is written.","Avoid manually editing/deleting references on frame code units.","Treat frames missing the PC reference as malformed and re-annotate them."],"tags":["stack-unwinding","references","annotations","data-integrity"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}