NationalSecurityAgency/ghidra · error · IllegalArgumentException

Function list cannot be null

Error message

Function list cannot be null

What it means

Thrown by the SFOverviewInfo constructor when the Set<FunctionSymbol> functions argument is null. SFOverviewInfo packages an overview (similarity overview, not full results) request; it requires at least one function symbol so the facade can compute signatures. This is the first of three ordered validations (null, then empty, then cross-program).

Source

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

public class SFOverviewInfo {

	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();
	}
	
	/**

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Null-check the selection before constructing SFOverviewInfo and abort the overview action with a user message when no functions are selected.
  2. Use Collections.emptySet() semantics upstream so null never reaches the constructor, then let the 'cannot be empty' check carry the message.
  3. Add Objects.requireNonNull(functions, "functions") at the call site for a clearer NPE if null truly indicates a bug.

Example fix

// before
SFOverviewInfo info = new SFOverviewInfo(selected);
// after
if (selected == null || selected.isEmpty()) {
    popup("Select at least one function first");
    return;
}
SFOverviewInfo info = new SFOverviewInfo(selected);
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 hasOverviewInput(Set<FunctionSymbol> fns) {
    return fns != null && !fns.isEmpty();
}

Try / catch

try {
    new SFOverviewInfo(functions);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("null")) { /* prompt user to select */ }
}

Prevention

When it happens

Trigger: new SFOverviewInfo(null); or passing a variable that was never assigned a non-null set (e.g. an empty selection result returned null).

Common situations: A plugin/dialog builds the set from the current selection and forwards it without checking when nothing is selected; refactoring that left a code path unable to populate the set.

Related errors


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