NationalSecurityAgency/ghidra · error · IllegalArgumentException
Given range's space must be in the factory's physical spaces
Error message
Given range's space must be in the factory's physical spaces
What it means
Thrown by GAddressRangeField.setRange() when the AddressRange's AddressSpace is not among the spaces the configured AddressFactory exposes. The widget maintains a fixed dropdown of spaces taken from the factory, so a range whose space is unknown cannot be displayed or edited. The factory must also already be set, or a different IllegalStateException fires first.
Source
Thrown at Ghidra/Debug/ProposedUtils/src/main/java/docking/widgets/model/GAddressRangeField.java:183
}
revalidateMin();
adjustMaxToMin();
}
protected void maxFocusLost(FocusEvent e) {
if (factory == null) {
return;
}
revalidateMax();
adjustMinToMax();
}
public void setRange(AddressRange range) {
if (factory == null) {
throw new IllegalStateException("Must set address factory first.");
}
if (!List.of(factory.getAddressSpaces()).contains(range.getAddressSpace())) {
throw new IllegalArgumentException(
"Given range's space must be in the factory's physical spaces");
}
fieldSpace.setSelectedItem(range.getAddressSpace().getName());
fieldMin.setText(Long.toUnsignedString(range.getMinAddress().getOffset(), 16));
fieldMax.setText(Long.toUnsignedString(range.getMaxAddress().getOffset(), 16));
}
public AddressRange getRange() {
String name = (String) fieldSpace.getSelectedItem();
if (name == null) {
return null;
}
AddressSpace space = Objects.requireNonNull(factory.getAddressSpace(name));
long min = Long.parseUnsignedLong(fieldMin.getText(), 16);
long max = Long.parseUnsignedLong(fieldMax.getText(), 16);
return new AddressRangeImpl(space.getAddress(min), space.getAddress(max));
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Always obtain the AddressRange from the same Program whose AddressFactory was passed to setAddressFactory().
- Before calling setRange, verify the space is known: Arrays.asList(factory.getAddressSpaces()).contains(range.getAddressSpace()).
- If the range came from a different program, rebuild it via this factory's getAddressSpace(name).getAddress(offset).
- Call setAddressFactory(program.getAddressFactory()) immediately after opening/switching the program, before any setRange call.
Example fix
// before
field.setAddressFactory(oldProgram.getAddressFactory());
field.setRange(otherProgramRange); // space from other factory
// after
field.setAddressFactory(currentProgram.getAddressFactory());
AddressFactory f = currentProgram.getAddressFactory();
AddressSpace sp = f.getAddressSpace(otherProgramRange.getAddressSpace().getName());
AddressRange remapped = new AddressRangeImpl(
sp.getAddress(otherProgramRange.getMinAddress().getOffset()),
sp.getAddress(otherProgramRange.getMaxAddress().getOffset()));
field.setRange(remapped); Defensive patterns
Strategy: validation
Validate before calling
AddressFactory f = field.getFactory != null ? program.getAddressFactory() : null;
AddressSpace sp = range.getAddressSpace();
boolean known = false;
for (AddressSpace s : program.getAddressFactory().getAddressSpaces()) {
if (s.equals(sp)) { known = true; break; }
}
if (!known) {
// rebuild range in this factory's space, or skip setRange
}
field.setRange(range); // only when known Try / catch
try {
field.setRange(range);
} catch (IllegalArgumentException e) {
// range space not in factory; rebuild or log and skip
Msg.warn(this, "Skipping range with unknown space: " + range, e);
} Prevention
- Always source AddressRange objects from the same Program whose factory backs the field.
- Call setAddressFactory(program.getAddressFactory()) right after opening/switching a program.
- Discard cached ranges across program reloads.
When it happens
Trigger: Calling setRange(range) where range.getAddressSpace() returns a space obtained from a different Program's AddressFactory, a custom/stack/register space the factory does not list, or a space from a stale program after re-opening. Also when mixing AddressRange objects built from AddressSpace constants that differ by name from the factory's registered spaces.
Common situations: Reusing one program's ranges against a GAddressRangeField configured with another program's factory; passing a range built on a constant space (e.g. EXTERNAL or HASH) into a field whose factory only knows memory spaces; holding a range across a program reload where the language/compiler spec changed and space names shifted.
Related errors
- No such address space: %s
- Unsupported value: {}
- Invalid value for {}
- Return address must be in {}
- Return address must be in {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/28d2b2ae7069c27b.
Report an issue: GitHub.