NationalSecurityAgency/ghidra · error · IllegalArgumentException

Invalid max: {max}

Error message

Invalid max: {max}

What it means

Symmetric to the min case: NEG_INF returns isValidMax()==false because nothing can be less-than-or-equal to -inf as an upper bound, so closed(..., NEG_INF) is impossible and IllegalArgumentException is thrown.

Source

Thrown at Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/database/FieldSpan.java:120

				? DOMAIN.closed(End.lower(from, fromInclusive), End.positiveInfinity())
				: DOMAIN.closed(End.negativeInfinity(), End.upper(from, fromInclusive));
	}

	/**
	 * The domain of field values, allowing open endpoints
	 */
	public class Domain extends EndDomain<Field, FieldSpan> {
		private Domain() {
			super(Field::compareTo);
		}

		@Override
		public FieldSpan closed(End<Field> min, End<Field> max) {
			if (!min.isValidMin()) {
				throw new IllegalArgumentException("Invalid min: " + min);
			}
			if (!max.isValidMax()) {
				throw new IllegalArgumentException("Invalid max: " + max);
			}
			return super.closed(min, max);
		}

		@Override
		public FieldSpan newSpan(End<Field> min, End<Field> max) {
			return new Impl(min, max);
		}

		@Override
		public FieldSpan empty() {
			return EMPTY;
		}

		@Override
		public FieldSpan all() {
			return ALL;
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Use a finite End or POS_INF for the max endpoint.
  2. Validate isValidMax() before calling closed() in generic code.
  3. Ensure bounds are ordered min <= max before construction.

Example fix

// before
span = domain.closed(someMin, End.NEG_INF);
// after
span = domain.closed(someMin, aFiniteOrPosInfMax);
Defensive patterns

Strategy: validation

Validate before calling

if (!max.isValidMax()) {
    // swap in a finite or POS_INF max before constructing the span
    return;
}

Prevention

When it happens

Trigger: A max endpoint whose isValidMax() is false - the builtin case is NEG_INF used as the upper bound.

Common situations: Inverted bounds leaking negative infinity into the max slot; generic range builders that don't validate endpoints; min/max swapped during construction.

Related errors


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