NationalSecurityAgency/ghidra · warning · IllegalArgumentException

Negative value not permitted for {}

Error message

Negative value not permitted for {}

What it means

Thrown by parsePositiveIntegerOption() when a numeric option value successfully parses as an integer but is negative (value < 0). Options parsed by this method include --limit, --maxfunc, and similar numeric configuration values that must be non-negative.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java:375

		if (params.length <= index) {
			throw new IllegalArgumentException("Missing required parameter: " + name);
		}
		String p = params[index];
		if (p.startsWith("--") || p.contains("=")) {
			throw new IllegalArgumentException(
				"Missing required parameter (" + name + ") before specified option: " + p);
		}
	}

	private Integer parsePositiveIntegerOption(String option) {
		String optionValue = optionValueMap.get(option);
		if (optionValue == null) {
			return null;
		}
		try {
			int value = Integer.valueOf(optionValue);
			if (value < 0) {
				throw new IllegalArgumentException("Negative value not permitted for " + option);
			}
			return value;
		}
		catch (NumberFormatException e) {
			throw new IllegalArgumentException("Invalid integer value specified for " + option);
		}
	}

	/**
	 * Runs the command specified by the given set of params.
	 * 
	 * @param params the parameters specifying the command
	 * @param monitor the task monitor
	 * @throws IllegalArgumentException if invalid params have been specified
	 * @throws Exception if there's an error during the operation
	 * @throws CancelledException if processing is cancelled
	 */
	public void run(String[] params, TaskMonitor monitor) throws Exception, CancelledException {

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Use a non-negative integer value for the option.
  2. If the intent is 'unlimited', check whether the option accepts a special value or can be omitted entirely.
  3. Validate computed values in scripts before passing them to BSim.

Example fix

// before
bsim listexes h2://localhost/db --limit -1
// error: Negative value not permitted for --limit

// after
bsim listexes h2://localhost/db --limit 100
Defensive patterns

Strategy: validation

Validate before calling

String limitStr = optionValueMap.get("--limit");
if (limitStr != null) {
    int val = Integer.parseInt(limitStr);
    if (val < 0) {
        throw new IllegalArgumentException("--limit must be non-negative, got: " + val);
    }
}

Prevention

When it happens

Trigger: Specifying a negative value for a numeric option, e.g., '--limit -5' or '--maxfunc=-10'. The value parses as a valid integer but fails the >= 0 check.

Common situations: Using a negative sentinel value (common in some CLI conventions); a variable or script that computes the limit producing a negative result; misunderstanding the valid range.

Related errors


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