NationalSecurityAgency/ghidra · error · QueryDatabaseException

Unable to signature functions

Error message

Unable to signature functions

What it means

Thrown as a QueryDatabaseException with the message 'Unable to signature functions' when creating a new GenSignatures instance or opening the program for signature generation fails with an LSHException. The GenSignatures constructor and openProgram() set up the BSim signature generation pipeline, and an LSHException here means the LSH configuration could not be initialized for the program.

Source

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

		int count = functions.size();
		try {
// TODO: do this work in a loop so that one failure doesn't stop the entire process...the 
//		 downside is losing parallelization
			signatureGenerator.scanFunctions(iter, count, monitor);
		}
		catch (DecompileException e) {
			throw new QueryDatabaseException(e);
		}
	}

	private GenSignatures createSignatureGenerator() throws QueryDatabaseException {
		try {
			GenSignatures newSignatureGenerator = new GenSignatures(false);
			newSignatureGenerator.openProgram(program, null, null, null, null, null);
			return newSignatureGenerator;
		}
		catch (LSHException e) {
			throw new QueryDatabaseException("Unable to signature functions", e);
		}
	}

	private StagingManager createStagingManager(int numqueries, int stages) {
		if (stages == 1) {
			return new NullStaging();
		}

		int numberOfFunctionsPerQuery;
		if (stages > numqueries) {
			// when the number of stages is greater than the number of functions, lower the stage
			// count to execute one function at a time (stages becomes numqueries)
			numberOfFunctionsPerQuery = 1;
		}
		else {
			numberOfFunctionsPerQuery = (int) Math.ceil(numqueries / stages);
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the Ghidra installation is complete and BSim configuration files exist in the expected resource directories.
  2. Check that the program object is fully loaded and valid before calling signature generation.
  3. Inspect the wrapped LSHException (via getCause()) for specific configuration file or resource paths that are missing.
  4. Reinstall or repair the Ghidra installation if BSim resource files are missing.
  5. Ensure the correct BSim template/configuration is specified if using a non-default setup.

Example fix

// before
gen.openProgram(program, null, null, null, null, null);

// after
File weightFile = resolveBsimWeights(); // ensure config present
if (!weightFile.exists()) {
    throw new IOException("BSim weight config missing: " + weightFile);
}
gen.openProgram(program, null, null, weightFile, null, null);
Defensive patterns

Strategy: validation

Validate before calling

// Verify BSim resources exist before creating the signature generator
ApplicationFile weights = findBsimResource("bsim_weights.xml");
if (weights == null || !weights.exists()) {
    throw new IllegalStateException(
        "BSim weight configuration not found; Ghidra installation may be incomplete");
}

Try / catch

try {
    GenSignatures gen = createSignatureGenerator();
} catch (QueryDatabaseException e) {
    if (e.getMessage().equals("Unable to signature functions")) {
        // Check the underlying LSHException for missing resource details
        LSHException cause = (LSHException) e.getCause();
        Msg.showError(this, null, "BSim Setup Error",
            "Cannot initialize BSim signatures: " + cause.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Occurs in createSignatureGenerator() when 'new GenSignatures(false)' or newSignatureGenerator.openProgram(program, ...) throws LSHException. This happens when the BSim configuration files (weight tables, category settings) are missing or corrupt, the program lacks required metadata for BSim analysis, or the LSH module cannot find/load necessary resources.

Common situations: BSim configuration directory is missing or corrupted. Ghidra installation is incomplete or BSim plugin data files are absent. The program was not properly loaded or initialized before calling signature generation. Running BSim in a custom/standalone environment without the full Ghidra resource layout.

Related errors


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