NationalSecurityAgency/ghidra · error · IllegalArgumentException

Function list cannot be null

Error message

Function list cannot be null

What it means

Thrown by the SFQueryInfo constructor when the Set<FunctionSymbol> functions argument is null. SFQueryInfo packages a full similar-function query (QueryNearest) and mirrors SFOverviewInfo's three ordered validations (null, empty, cross-program). It is a programmer/argument error, not a runtime DB condition.

Source

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

	public static final int DEFAULT_QUERIES_PER_STAGE = 10;

	private Set<FunctionSymbol> functions;
	private Program program;

	private QueryNearest queryNearest;
	private BSimFilter bsimFilter;
	private PreFilter preFilter;

	/**
	 * Constructs a query request with default parameters.
	 * @param functions required--a set of functions (at least one) for which similar functions
	 *                  will searched.  All functions must be from the same program.
	 * @throws IllegalArgumentException if {@code functions} is {@code null}/empty or functions
	 * are from multiple programs.  
	 */
	public SFQueryInfo(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");
			}
		}
		queryNearest = new QueryNearest();
		bsimFilter = new BSimFilter();

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Null-check the selection before constructing SFQueryInfo and abort the search action with a user message.
  2. Ensure upstream providers never return null (return empty set instead), letting the empty-check handle the message.
  3. Use Objects.requireNonNull at the call site to fail fast with a clear cause during development.

Example fix

// before
SFQueryInfo info = new SFQueryInfo(selected);
// after
if (selected == null || selected.isEmpty()) {
    setStatusMessage("Select one or more functions");
    return;
}
SFQueryInfo info = new SFQueryInfo(selected);
Defensive patterns

Strategy: validation

Validate before calling

if (functions == null || functions.isEmpty()) {
    setStatusMessage("Select one or more functions");
    return;
}
SFQueryInfo info = new SFQueryInfo(functions);

Type guard

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

Try / catch

try {
    new SFQueryInfo(functions);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("null")) { /* prompt for selection */ }
}

Prevention

When it happens

Trigger: new SFQueryInfo(null); or forwarding an unassigned selection result.

Common situations: A BSim search dialog/action that builds the set from a selection and forwards it without a null guard; refactoring leaving a null path.

Related errors


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