NationalSecurityAgency/ghidra · error · IllegalStateException
There is no current program
Error message
There is no current program
What it means
Thrown by FlatDebuggerAPI.requireCurrentProgram() when there is no current static program (the Ghidra Program being analyzed, distinct from a dynamic trace view). This is the standard CodeBrowser program, used for static-to-dynamic mapping.
Source
Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/flatapi/FlatDebuggerAPI.java:517
* This is implemented by virtue of extending {@link FlatProgramAPI}, which is inherited via
* {@link GhidraScript}.
*
* @return the current program
*/
default Program getCurrentProgram() {
return getState().getCurrentProgram();
}
/**
* Get the current program, throwing an exception if there isn't one.
*
* @return the current program
* @throws IllegalStateException if there is no current program
*/
default Program requireCurrentProgram() {
Program program = getCurrentProgram();
if (program == null) {
throw new IllegalStateException("There is no current program");
}
return program;
}
/**
* Translate the given static location to the corresponding dynamic location
*
* <p>
* This uses the trace's static mappings (see {@link Trace#getStaticMappingManager()} and
* {@link DebuggerStaticMappingService}) to translate a static location to the corresponding
* dynamic location in the current trace. If there is no current trace or the location cannot be
* translated to the current trace, the result is null. This accommodates link-load-time
* relocation, particularly from address-space layout randomization (ASLR).
*
* @param location the static location, e.g., from {@link #staticLocation(String)}
* @return the dynamic location, or null if not translated
*/
default ProgramLocation translateStaticToDynamic(ProgramLocation location) {View on GitHub (pinned to d5f144c24d)
Solutions
- Open or import a program in the tool before running the script.
- Guard with getCurrentProgram() != null before calling requireCurrentProgram().
- For static/dynamic mapping flows, ensure a static program is loaded alongside the trace.
Example fix
// before
Program p = requireCurrentProgram(); // throws if none
// after
Program p = getCurrentProgram();
if (p == null) {
println("Open a program first");
return;
} Defensive patterns
Strategy: type-guard
Validate before calling
Program p = getCurrentProgram();
if (p == null) {
println("No current program; open/import one first");
return;
} Type guard
static boolean hasCurrentProgram(FlatDebuggerAPI api) {
return api.getCurrentProgram() != null;
} Try / catch
try {
Program p = requireCurrentProgram();
} catch (IllegalStateException e) {
if (e.getMessage().equals("There is no current program")) {
// prompt to open a program, then retry
} else throw e;
} Prevention
- Open or import a static program before running static-mapping scripts.
- Check getCurrentProgram() != null as a precondition.
When it happens
Trigger: Calling requireCurrentProgram() when getState().getCurrentProgram() returns null.
Common situations: No program imported/open in the tool; running a script that assumes a static program is open but none is; program was closed before the script ran.
Related errors
- There is no current trace
- There is no current thread
- There is no current trace view
- Tool does not have service {cls}! This script should be run
- There is no trace
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/5184b6d0ddf0148b.
Report an issue: GitHub.