NationalSecurityAgency/ghidra · error · IllegalStateException

Static program is not opened

Error message

Static program is not opened

What it means

MappingEntry lazily resolves the destination Program for a static mapping; the program field is null when that program is not (or no longer) open in the tool. mapTraceAddressToProgramLocation() requires the resolved program to build a ProgramLocation, so it throws IllegalStateException("Static program is not opened") when program == null.

Source

Thrown at Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/MappingEntry.java:163

		return staticRange.contains(address);
	}

	public boolean isInProgramRange(AddressRange rng) {
		if (staticRange == null) {
			return false;
		}
		return staticRange.intersects(rng);
	}

	protected Address mapTraceAddressToProgram(Address address) {
		assert isInTraceRange(address, null);
		long offset = address.subtract(mapping.getMinTraceAddress());
		return staticRange.getMinAddress().addWrapSpace(offset);
	}

	public ProgramLocation mapTraceAddressToProgramLocation(Address address) {
		if (program == null) {
			throw new IllegalStateException("Static program is not opened");
		}
		return new ProgramLocation(program, mapTraceAddressToProgram(address));
	}

	public AddressRange mapTraceRangeToProgram(AddressRange rng) {
		assert isInTraceRange(rng, null);
		AddressRange part = rng.intersect(mapping.getTraceAddressRange());
		Address min = mapTraceAddressToProgram(part.getMinAddress());
		Address max = mapTraceAddressToProgram(part.getMaxAddress());
		return new AddressRangeImpl(min, max);
	}

	protected Address mapProgramAddressToTrace(Address address) {
		assert isInProgramRange(address);
		long offset = address.subtract(staticRange.getMinAddress());
		return mapping.getMinTraceAddress().addWrapSpace(offset);
	}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Open the static program referenced by the mapping in the tool, then re-resolve mappings.
  2. Guard before calling mapTraceAddressToProgramLocation by checking the entry has a resolved program (or that the program is open).
  3. If the program is gone, remove/refresh the stale mapping entries.

Example fix

// before
ProgramLocation loc = entry.mapTraceAddressToProgramLocation(addr); // throws if program closed

// after
Program referenced = findReferencedProgram(entry);
if (referenced == null || !programManager.isOpen(referenced)) {
    programManager.openProgram(referenced);
}
ProgramLocation loc = entry.mapTraceAddressToProgramLocation(addr);
Defensive patterns

Strategy: validation

Validate before calling

// Before mapping a trace address to a program location, ensure the program is open
Program referenced = entry.getReferencedProgram(); // resolve via mapping URL
if (referenced == null || !programManager.isOpen(referenced)) {
    programManager.openProgram(referenced);
}

Type guard

public static boolean mappingProgramIsOpen(MappingEntry entry,
        DebuggerProgramManager pm) {
    // MappingEntry.program is package-private; expose via a method that returns it
    return entry.getProgram() != null; // null means not resolved/open
}

Try / catch

try {
    ProgramLocation loc = entry.mapTraceAddressToProgramLocation(addr);
} catch (IllegalStateException e) {
    if (e.getMessage().equals("Static program is not opened")) {
        programManager.openProgram(resolveProgramFromMapping(entry));
        ProgramLocation loc = entry.mapTraceAddressToProgramLocation(addr);
    } else throw e;
}

Prevention

When it happens

Trigger: Translating a trace address to a program location via a MappingEntry whose static program has been closed. Querying mappings before the referenced program has been opened/resolved. The program's domain file was removed or renamed so it cannot be resolved.

Common situations: User closes the static program that a mapping points to, then continues navigating/mapping in the debugger. Headless flows that build mappings without opening the referenced programs. Stale mapping entries after program re-import under a new name.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/59d0632526302f55. Report an issue: GitHub.