NationalSecurityAgency/ghidra · error · QueryDatabaseException

${e.getMessage()}

Error message

${e.getMessage()}

What it means

Thrown by SimilarFunctionQueryService.generateQueryNearest when signatureGenerator.transferCachedFunctions raises an LSHException while copying cached function signatures into the query's manage record. The facade wraps it into a QueryDatabaseException carrying only e.getMessage(). generateQueryNearest builds a QueryNearest request and pre-stages signatures before the network query.

Source

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

	 * server.  This involves generating the signatures for each of the function and accumulating their
	 * FunctionDescriptions
	 * @param queryInfo   is the high-level form of query, with the list of FunctionSymbols and other parameters
	 * @param monitor the task monitor
	 * @return the QueryNearest object ready for the queryStaged method
	 * @throws QueryDatabaseException if transferring functions fails
	 */
	public QueryNearest generateQueryNearest(SFQueryInfo queryInfo, TaskMonitor monitor)
			throws QueryDatabaseException {
		QueryNearest result = queryInfo.buildQueryNearest();
		doSignatureGeneration(queryInfo.getFunctions(), monitor);
		FunctionSymbolIterator iter =
			new FunctionSymbolIterator(queryInfo.getFunctions().iterator());
		try {
			signatureGenerator.transferCachedFunctions(result.manage, iter,
				queryInfo.getPreFilter());
		}
		catch (LSHException e) {
			throw new QueryDatabaseException(e.getMessage());
		}
		return result;
	}

	public QueryNearestVector generateQueryNearestVector(SFOverviewInfo overviewInfo,
			TaskMonitor monitor) throws QueryDatabaseException {
		QueryNearestVector result = overviewInfo.buildQueryNearestVector();
		doSignatureGeneration(overviewInfo.getFunctions(), monitor);
		FunctionSymbolIterator iter =
			new FunctionSymbolIterator(overviewInfo.getFunctions().iterator());
		try {
			signatureGenerator.transferCachedFunctions(result.manage, iter,
				overviewInfo.getPreFilter());
		}
		catch (LSHException e) {
			throw new QueryDatabaseException(e.getMessage());
		}
		return result;

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Ensure all selected functions have disassembled bodies and valid signatures before querying (analyze the program first).
  2. Reopen/refresh the program if it was modified or closed since selection.
  3. Inspect the wrapped LSHException message for the root cause; if you need the cause object, call the underlying signatureGenerator path directly rather than the facade.
  4. Narrow the selection to functions known to have generated signatures.

Example fix

// before
QueryNearest q = service.generateQueryNearest(queryInfo, monitor);
// after: ensure program analyzed, then surface cause
try {
    QueryNearest q = service.generateQueryNeast(queryInfo, monitor);
} catch (QueryDatabaseException e) {
    log.warning("Signature transfer failed: " + e.getMessage());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure every selected function is analyzed/has a signature
for (FunctionSymbol s : queryInfo.getFunctions()) {
    if (s.getFunction() == null || s.getFunction().getBody().isEmpty()) {
        throw new IllegalStateException("Function lacks body: " + s.getName());
    }
}

Try / catch

try {
    QueryNearest q = service.generateQueryNearest(queryInfo, monitor);
} catch (QueryDatabaseException e) {
    log.warning("Signature staging failed: " + e.getMessage());
    // narrow selection to analyzable functions and retry
}

Prevention

When it happens

Trigger: A signature-generation/transfer failure during query preparation: missing cached signature data for a selected function, a function that cannot be disassembled/hashed, or a pre-filter rejecting the function. The original LSHException detail is preserved only in the message string.

Common situations: Selected function lacks a body or signature (thunk/external); signature cache invalidated mid-run; program closed/modified between selection and query; preFilter configuration excludes the function.

Related errors


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