NationalSecurityAgency/ghidra · error · UnwindException
No function contains {pc}
Error message
No function contains {pc} What it means
Thrown by UnwindAnalysis.AnalysisForPC constructor when the program counter address does not fall within any function in the program's FunctionManager. The analysis requires a containing function to build the basic block graph and compute unwind information, so without one, it cannot proceed.
Source
Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/stack/UnwindAnalysis.java:163
private final DijkstraShortestPathsAlgorithm<BlockVertex, BlockEdge> pathFinder;
private final Set<StackUnwindWarning> warnings = new LinkedHashSet<>();
/**
* Begin analysis for unwinding a frame, knowing only the program counter for that frame
*
* <p>
* This will look up the function containing the program counter. If there's isn't one, then
* this analysis cannot proceed.
*
* @param pc the program counter
* @param monitor a monitor for progress and cancellation
* @throws CancelledException if the monitor cancels the analysis
*/
public AnalysisForPC(Address pc, TaskMonitor monitor) throws CancelledException {
this.pc = pc;
this.function = program.getFunctionManager().getFunctionContaining(pc);
if (function == null) {
throw new UnwindException("No function contains " + pc);
}
this.monitor = monitor;
this.graph = new BlockGraph(monitor);
this.pathFinder =
new DijkstraShortestPathsAlgorithm<>(graph, GEdgeWeightMetric.unitMetric());
this.pcBlock = new BlockVertex(
Unique.assertAtMostOne(blockModel.getCodeBlocksContaining(pc, monitor)));
}
/**
* Compute the shortest path(s) from function entry to the program counter
*
* @return the paths. There's usually only one
* @throws CancelledException if the monitor cancels the analysis
*/
public Collection<Deque<BlockEdge>> getEntryPaths() throws CancelledException {
BlockVertex entryBlock = new BlockVertex(Unique.assertAtMostOne(
blockModel.getCodeBlocksContaining(function.getEntryPoint(), monitor)));View on GitHub (pinned to d5f144c24d)
Solutions
- Run auto-analysis on the program to create functions covering the PC address.
- Manually create a function at or containing the PC address (right-click > Create Function in listing).
- Verify the PC value is correct — check that the trace-to-program mapping resolved the right address.
- If the address is legitimately not in a function (e.g., JIT, shellcode), define a function there manually.
Example fix
// No code fix; ensure a function exists at the PC: // In Ghidra: navigate to PC address > right-click > Create Function // Or programmatically: // new CreateFunctionCmd(pcAddress).applyTo(program);
Defensive patterns
Strategy: validation
Validate before calling
// Before calling UnwindAnalysis, verify a function contains the PC:
Function fn = program.getFunctionManager().getFunctionContaining(pc);
if (fn == null) {
// trigger auto-analysis or create function before unwinding
} Type guard
private boolean isPcInFunction(Address pc, Program program) {
return program.getFunctionManager().getFunctionContaining(pc) != null;
} Try / catch
try {
new AnalysisForPC(pc, monitor).computeUnwindInfo();
} catch (UnwindException e) {
if (e.getMessage().startsWith("No function contains")) {
// auto-create function, then retry
} else { throw e; }
} Prevention
- Run full auto-analysis before invoking unwind analysis.
- Ensure the program mapping resolves the PC to an address within a defined function.
- Create functions manually in code regions that auto-analysis missed.
- Verify PC values are correct — wrong mappings produce addresses in non-code regions.
When it happens
Trigger: AnalysisForPC constructor calls program.getFunctionManager().getFunctionContaining(pc) which returns null. Occurs when the PC is in a code region that has no defined function — e.g., the address is in the middle of data, in unanalyzed code, or the function boundaries don't cover it.
Common situations: Auto-analysis hasn't been run or was incomplete. The PC is in a code cave, jump table, or data region that Ghidra doesn't recognize as code. The function was split or the disassembly created a gap. The program mapping points to the wrong address.
Related errors
- The function for the frame is no longer present in the mappe
- Could not find a path from {function} entry to {pc}
- Cannot find static program for frame ({pc}={pcVal})
- Unsupported value: {}
- Invalid value for {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/33099aba2b3e591d.
Report an issue: GitHub.