{"record":{"id":"9df4ad90bc5864c2","repo":"NationalSecurityAgency/ghidra","slug":"could-not-uniquely-match-executable","errorCode":null,"errorMessage":"Could not (uniquely) match executable","messagePattern":"Could not \\(uniquely\\) match executable","errorType":"validation","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java","lineNumber":2081,"sourceCode":"\t * @param query the query to execute\n\t * @throws LSHException if the database does not track callgraph or the function is not found\n\t * @throws SQLException if there is an error issuing the query\n\t */\n\tprivate void fdbQueryChildren(QueryChildren query) throws LSHException, SQLException {\n\t\tif (!info.trackcallgraph) {\n\t\t\tthrow new LSHException(\"Database does not track callgraph\");\n\t\t}\n\t\tResponseChildren response = query.childrenresponse;\n\t\tExecutableRecord exe = null;\n\n\t\tif (query.md5sum.length() != 0) {\n\t\t\texe = queryExecutableByMd5(query.md5sum, response.manage);\n\t\t}\n\t\telse {\n\t\t\texe = exeTable.querySingleExecutable(response.manage, query.name_exec, query.arch,\n\t\t\t\tquery.name_compiler);\n\t\t\tif (exe == null) {\n\t\t\t\tthrow new LSHException(\"Could not (uniquely) match executable\");\n\t\t\t}\n\t\t}\n\t\tfor (FunctionEntry entry : query.functionKeys) {\n\t\t\tFunctionDescription func =\n\t\t\t\tqueryByNameAddress(response.manage, exe, entry.funcName, entry.address, true);\n\t\t\tif (func == null) {\n\t\t\t\tthrow new LSHException(\"Could not find function: \" + entry.funcName);\n\t\t\t}\n\t\t\tresponse.correspond.add(func);\n\t\t}\n\n\t\tTreeMap<RowKey, FunctionDescription> funcmap = new TreeMap<>();\n\t\tresponse.manage.generateFunctionIdMap(funcmap);\n\t\tfor (FunctionDescription element : response.correspond) {\n\t\t\tfillinChildren(element, response.manage, funcmap);\n\t\t}\n\t}\n","sourceCodeStart":2063,"sourceCodeEnd":2099,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java#L2063-L2099","documentation":"In `fdbQueryChildren`, when no MD5 is supplied, `querySingleExecutable` resolves by name/arch/compiler. A null return -- meaning either no match or a non-unique (ambiguous) match -- causes LSHException(\"Could not (uniquely) match executable\"). The 'uniquely' signals that multiple executables sharing the name cannot be disambiguated.","triggerScenarios":"Querying children by name where either no executable matches, or more than one executable matches the name (different architectures/compilers not disambiguated by the provided fields).","commonSituations":"Same executable name across architectures; compiler not specified; typo in name; multiple ingested builds of the same program name.","solutions":["Provide the MD5 (query.md5sum) for an exact, unambiguous match.","Specify arch and name_compiler to disambiguate name-based matches.","Verify the executable exists and is uniquely keyed."],"exampleFix":"// before: name-only, ambiguous across arches\nquery.name_exec = \"myapp\";\n// after: disambiguate via md5 (preferred) or arch+compiler\nquery.md5sum = \"<exact md5>\";","handlingStrategy":"validation","validationCode":"// Resolve ambiguity before querying: require md5, or confirm a unique name match.\nif (query.md5sum == null || query.md5sum.isEmpty()) {\n    int matches = exeTable.countByNameArchCompiler(\n        query.name_exec, query.arch, query.name_compiler);\n    if (matches != 1) {\n        throw new IllegalArgumentException(\n            \"Executable not uniquely matched (\" + matches + \"); provide md5\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    db.fdbQueryChildren(query);\n} catch (LSHException e) {\n    if (e.getMessage().equals(\"Could not (uniquely) match executable\")) {\n        // ask caller to disambiguate via md5 or arch+compiler\n        throw new AmbiguousExecutableException(\"Provide md5 or arch/compiler\", e);\n    }\n    throw e;\n}","preventionTips":["Prefer MD5 for exact executable resolution.","Require arch and compiler for any name-based children query.","Pre-check match cardinality before dispatching."],"tags":["database","query","executable","ambiguous","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}