{"record":{"id":"6521565705e71918","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-find-functiondescription","errorCode":null,"errorMessage":"Unable to find FunctionDescription","messagePattern":"Unable to find FunctionDescription","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/description/DescriptionManager.java","lineNumber":442,"sourceCode":"\t\tthrow new LSHException(\"Unable to find executable\");\n\t}\n\n\t/**\n\t * Find a function (within an executable) by its name and address (both must be provided)\n\t * If the request function does not exist, an exception is thrown\n\t * @param fname - the name of the function\n\t * @param address - the address of the function\n\t * @param exe - the ExecutableRecord containing the function\n\t * @return the FunctionDescription\n\t * @throws LSHException if a matching function does not exist\n\t */\n\tpublic FunctionDescription findFunction(String fname, long address, ExecutableRecord exe)\n\t\t\tthrows LSHException {\n\t\tFunctionDescription fdesc = new FunctionDescription(exe, fname, address);\n\n\t\tFunctionDescription res = funcrec.floor(fdesc);\n\t\tif (res == null || (!res.equals(fdesc))) {\n\t\t\tthrow new LSHException(\"Unable to find FunctionDescription\");\n\t\t}\n\t\treturn res;\n\t}\n\n\t/**\n\t * Find a function within an executable by name. The name isn't guaranteed to be unique. If there\n\t * are more than one, the first in address order is returned. If none are found, null is returned\n\t * @param fname is the name of the function to match\n\t * @param exe is the ExecutableRecord containing the function\n\t * @return a FunctionDescription or null \n\t */\n\tpublic FunctionDescription findFunctionByName(String fname, ExecutableRecord exe) {\n\t\tFunctionDescription fdesc = new FunctionDescription(exe, fname, 0);\n\t\tFunctionDescription res = funcrec.ceiling(fdesc);\n\t\tif (res == null || !fname.equals(res.getFunctionName()) ||\n\t\t\t!res.getExecutableRecord().equals(exe)) {\n\t\t\treturn null;\n\t\t}","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/description/DescriptionManager.java#L424-L460","documentation":"Thrown by DescriptionManager.findFunction(String fname, long address, ExecutableRecord exe) when the function description keyed by (name, address, parent executable) is not present. It constructs a FunctionDescription template and uses funcrec.floor(); if the floor is null or not equal to the template, no matching function exists.","triggerScenarios":"Calling findFunction(fname, address, exe) where exe has no FunctionDescription with both the given name and address. Reached during query result resolution or XML restore when a referenced function has not been inserted.","commonSituations":"Looking up a function before inserting it; address computed in the wrong address space/offset; name normalized differently (demangled vs mangled); referencing a function from a different executable record; executable record mismatch (right name, wrong exe object).","solutions":["Insert the FunctionDescription (via newFunction) before calling findFunction.","Confirm the address long matches the entry-point address stored at insert time.","Verify the ExecutableRecord passed is the same instance that owns the function.","Catch LSHException and fall back to findFunctionByName if address is uncertain."],"exampleFix":"// before\nFunctionDescription f = man.findFunction(fname, address, exe); // throws\n\n// after\nFunctionDescription f = man.findFunctionByName(fname, exe); // null-tolerant fallback","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return man.findFunction(fname, address, exe);\n} catch (LSHException e) {\n    return man.findFunctionByName(fname, exe); // null-tolerant\n}","preventionTips":["Insert the FunctionDescription (newFunction) before looking it up.","Confirm the address matches the stored entry-point address.","Pass the owning ExecutableRecord instance, not an equivalent rebuilt one."],"tags":["bsim","lookup","missing-data","java"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}