{"record":{"id":"ca4684291ce2f943","repo":"NationalSecurityAgency/ghidra","slug":"e1-getmessage","errorCode":null,"errorMessage":"${e1.getMessage()}","messagePattern":"\\$\\{e1\\.getMessage\\(\\)\\}","errorType":"exception","errorClass":"QueryDatabaseException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java","lineNumber":472,"sourceCode":"\t\t\treturn false;\n\t\t}\n\t\treturn database.getURLString().equals(serverURLString);\n\t}\n\n\tprivate void doSignatureGeneration(Set<FunctionSymbol> functions, TaskMonitor monitor)\n\t\t\tthrows QueryDatabaseException {\n\t\tif (functions.isEmpty()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (signatureGenerator == null) {\n\t\t\tsignatureGenerator = createSignatureGenerator();\n\t\t}\n\t\ttry {\n\t\t\tsignatureGenerator.setVectorFactory(database.getLSHVectorFactory());\n\t\t}\n\t\tcatch (LSHException e1) {\n\t\t\tthrow new QueryDatabaseException(e1);\n\t\t}\n\n\t\tmonitor.setMessage(\"Hashing function signatures...\");\n\t\tFunctionSymbolIterator iter = new FunctionSymbolIterator(functions.iterator());\n\t\tint count = functions.size();\n\t\ttry {\n// TODO: do this work in a loop so that one failure doesn't stop the entire process...the \n//\t\t downside is losing parallelization\n\t\t\tsignatureGenerator.scanFunctions(iter, count, monitor);\n\t\t}\n\t\tcatch (DecompileException e) {\n\t\t\tthrow new QueryDatabaseException(e);\n\t\t}\n\t}\n\n\tprivate GenSignatures createSignatureGenerator() throws QueryDatabaseException {\n\t\ttry {\n\t\t\tGenSignatures newSignatureGenerator = new GenSignatures(false);","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java#L454-L490","documentation":"Thrown as a QueryDatabaseException wrapping an LSHException when signatureGenerator.setVectorFactory(database.getLSHVectorFactory()) fails. The LSHVectorFactory obtained from the database cannot be applied to the GenSignatures generator, typically because the vector factory configurations are incompatible (different LSH parameters, weight tables, or vector dimensions).","triggerScenarios":"Occurs in doSignatureGeneration() when the signature generator (created from the local program) and the database's vector factory use mismatched LSH settings. This happens when the program's BSim weighting/layout differs from the database's — for example, the database was built with a different weight configuration file, or the client's BSim settings were changed after the program was loaded.","commonSituations":"Program was loaded with one BSim weight configuration, but the database uses a different one. The user changed BSim settings or upgraded Ghidra, altering the default LSH parameters. Cross-referencing a program against a database built by a different Ghidra version with incompatible vector factories.","solutions":["Ensure the BSim weight configuration and LSH parameters used to generate signatures match those of the target database.","Re-generate the program's signatures using the same BSim settings the database was built with.","Check getDatabaseCompatibility() before calling generateSignatures to detect layout mismatches early.","If the database is old, consider rebuilding it with the current Ghidra version's BSim settings."],"exampleFix":"// before\nString compat = service.getDatabaseCompatibility();\nif (compat != null) {\n    // proceed anyway -> LSHException from setVectorFactory\n    service.generateSignatures(functions, monitor);\n}\n\n// after\nString compat = service.getDatabaseCompatibility();\nif (compat != null) {\n    Msg.showError(this, null, \"BSim Incompatible\", compat);\n    return;\n}\nservice.generateSignatures(functions, monitor);","handlingStrategy":"validation","validationCode":"// Check layout compatibility before generating signatures\nString compat = service.getDatabaseCompatibility();\nif (compat != null) {\n    throw new IllegalStateException(\n        \"Cannot generate signatures: \" + compat);\n}","typeGuard":null,"tryCatchPattern":"try {\n    service.generateSignatures(functions, monitor);\n} catch (QueryDatabaseException e) {\n    if (e.getCause() instanceof LSHException) {\n        Msg.showError(this, null, \"BSim Vector Mismatch\",\n            \"The program's BSim settings are incompatible with the database. \" +\n            \"Re-generate the database or use matching BSim weights.\");\n    }\n    throw e;\n}","preventionTips":["Always call getDatabaseCompatibility() and check for null before generating signatures.","Ensure the BSim weight configuration used for the program matches the database.","Document which BSim weight file was used to build each database.","After upgrading Ghidra, check if BSim vector format changed before using old databases."],"tags":["bsim","lsh","vector-factory","configuration-mismatch","signatures"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}