NationalSecurityAgency/ghidra · error · LSHException
Query cannot be function staged
Error message
Query cannot be function staged
What it means
Thrown by FunctionStaging.initialize when the BSimQuery passed to it has a null DescriptionManager (q.getDescriptionManager() returns null). FunctionStaging splits a large query into batches by copying function descriptions from the global manager into per-stage local copies. Without a DescriptionManager, there are no function descriptions to stage, so the query type is incompatible with function-level staging.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/protocol/FunctionStaging.java:46
private DescriptionManager gmanage; // The global function manager
private DescriptionManager imanage; // The internal function manager
public FunctionStaging(int stagesize) {
this.stagesize = stagesize;
localQuery = null;
}
@Override
public BSimQuery<?> getQuery() {
return localQuery;
}
@Override
public boolean initialize(BSimQuery<?> q) throws LSHException {
globalQuery = q;
gmanage = q.getDescriptionManager();
if (gmanage == null)
throw new LSHException("Query cannot be function staged");
totalsize = gmanage.numFunctions();
queriesmade = 0;
localQuery = q.getLocalStagingCopy();
imanage = localQuery.getDescriptionManager();
curiter = gmanage.listAllFunctions();
imanage.clear();
imanage.transferSettings(gmanage);
int count;
for (count = 0; count < stagesize; ++count) {
if (!curiter.hasNext())
break;
imanage.transferFunction(curiter.next(), true); // Copy the next function into manager for this stage
queriesmade += 1;
}
return (count != 0);
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Only use FunctionStaging with query types that carry function descriptions (QueryNearest, QueryName, InsertRequest, etc.). Check q.getDescriptionManager() != null before creating the FunctionStaging.
- Use the appropriate staging strategy for the query type — not all queries need or support function staging.
- Add a guard in the caller: if (q.getDescriptionManager() == null) skip staging or use a different StagingManager.
- Review the BSimQuery hierarchy to understand which subclasses override getDescriptionManager() with a non-null return.
Example fix
// before
public boolean initialize(BSimQuery<?> q) throws LSHException {
globalQuery = q;
gmanage = q.getDescriptionManager();
if (gmanage == null)
throw new LSHException("Query cannot be function staged");
...
}
// caller fix
// before:
// FunctionStaging staging = new FunctionStaging(20);
// staging.initialize(anyQuery);
// after:
// if (anyQuery.getDescriptionManager() != null) {
// FunctionStaging staging = new FunctionStaging(20);
// staging.initialize(anyQuery);
// } else {
// // use non-staged execution
// } Defensive patterns
Strategy: validation
Validate before calling
// Check whether the query supports function staging before creating FunctionStaging
if (q.getDescriptionManager() == null) {
throw new IllegalArgumentException(
"Query type " + q.getClass().getSimpleName() +
" does not support function staging (no DescriptionManager).");
}
FunctionStaging staging = new FunctionStaging(20);
staging.initialize(q); Type guard
public static boolean supportsFunctionStaging(BSimQuery<?> q) {
return q != null && q.getDescriptionManager() != null;
} Try / catch
// No retry possible — this is a type incompatibility.
// Validate before staging and fall back to non-staged execution.
if (supportsFunctionStaging(query)) {
FunctionStaging staging = new FunctionStaging(stagesize);
staging.initialize(query);
// staged execution
} else {
// Execute without staging
query.execute(querydb);
} Prevention
- Check q.getDescriptionManager() != null before wrapping any BSimQuery in FunctionStaging.
- Only use FunctionStaging with query types that involve function descriptions (QueryNearest, QueryName, InsertRequest, etc.).
- Review the BSimQuery class hierarchy to understand which subclasses provide a DescriptionManager.
- Add a guard in generic code paths that apply staging to arbitrary BSimQuery instances.
When it happens
Trigger: Calling FunctionStaging.initialize with a BSimQuery subclass whose getDescriptionManager() returns null. Not all BSimQuery types carry a DescriptionManager — query types that don't involve function metadata (e.g., QueryInfo, CreateDatabase, InstallTagRequest, PasswordChange) return null. Attempting to function-stage these is a programming error.
Common situations: A caller incorrectly wraps a non-function query (like QueryInfo or CreateDatabase) in a FunctionStaging manager, expecting it to batch by functions; a code path that generically applies FunctionStaging to any BSimQuery without checking whether the query type supports function staging.
Related errors
- only DBTrace objects are supported
- only DBTrace files are supported
- Value '{address}' does not evaluate to an int
- {node} is not {err_msg}
- {object} is not {err_msg}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/3255322fdd5d26cb.
Report an issue: GitHub.