NationalSecurityAgency/ghidra · error · IllegalArgumentException

Function list cannot be empty

Error message

Function list cannot be empty

What it means

Thrown by the SFOverviewInfo constructor when the Set<FunctionSymbol> functions is non-null but empty (isEmpty()). The overview requires at least one function to hash and query; an empty set would produce a meaningless request. It is the second ordered check after the null check.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SFOverviewInfo.java:45

	public static final int DEFAULT_QUERIES_PER_STAGE  = 10;		// Default number of separate function queries to make at one time
	
	private Set<FunctionSymbol> functions;
	private Program program;
	private QueryNearestVector queryNearestVector;
	private PreFilter preFilter;
	
	/**
	 * Constructs an overview request with default parameters.
	 * @param functions required--a set of functions (at least one) for which an overview will be 
	 * 					computed.  All functions must be from the same program.
	 * @throws IllegalArgumentException if {@code functions} is {@code null}/empty or functions
	 * are from multiple programs.  
	 */
	public SFOverviewInfo(Set<FunctionSymbol> functions) {
		if (functions == null)
			throw new IllegalArgumentException("Function list cannot be null");
		if (functions.isEmpty())
			throw new IllegalArgumentException("Function list cannot be empty");
		
		this.functions = functions;
		for (FunctionSymbol s : functions) {
			if (program == null) {
				program = s.getProgram();
			}
			else if (program != s.getProgram()) {
				throw new IllegalArgumentException(
					"all function symbols are not from the same program");
			}
		}
		queryNearestVector = new QueryNearestVector();
		preFilter = new PreFilter();
	}
	
	/**
	 * @return the program from which all queried functions are from
	 */

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Guard the action entry point: if the selection set is empty, inform the user and skip construction.
  2. When iterating, skip iterations that resolve to an empty set rather than constructing SFOverviewInfo.
  3. Ensure selection providers return non-empty sets by filtering to functions-only at the UI layer.

Example fix

// before
Set<FunctionSymbol> syms = getSelectedFunctions();
SFOverviewInfo info = new SFOverviewInfo(syms);
// after
Set<FunctionSymbol> syms = getSelectedFunctions();
if (syms == null || syms.isEmpty()) { return; }
SFOverviewInfo info = new SFOverviewInfo(syms);
Defensive patterns

Strategy: validation

Validate before calling

if (functions == null || functions.isEmpty()) {
    popup("Select at least one function first");
    return;
}
SFOverviewInfo info = new SFOverviewInfo(functions);

Type guard

static boolean nonEmptyFunctions(Set<FunctionSymbol> fns) {
    return fns != null && !fns.isEmpty();
}

Try / catch

try {
    new SFOverviewInfo(functions);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("empty")) { /* inform user */ }
}

Prevention

When it happens

Trigger: new SFOverviewInfo(Set.of()) or passing a set that was populated from a selection filter that matched nothing.

Common situations: User runs the overview action with nothing selected or with a filter that yields zero functions; programmatic batch loop whose current item resolved to no symbols.

Related errors


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