{"record":{"id":"93770e9b16eac634","repo":"NationalSecurityAgency/ghidra","slug":"function-name-conflict-occurred-when-applying-func","errorCode":null,"errorMessage":"Function name conflict occurred when applying function signature.","messagePattern":"Function name conflict occurred when applying function signature\\.","errorType":"exception","errorClass":"InvalidInputException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionSignatureCmd.java","lineNumber":398,"sourceCode":"\n\t\tSymbolUtilities.validateName(name);\n\t\tif (function.getName().equals(name)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (functionRenameOption == FunctionRenameOption.RENAME_IF_DEFAULT &&\n\t\t\tfunction.getSymbol().getSource() != SourceType.DEFAULT) {\n\t\t\t// not default and we are not forcing the rename\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tremoveCodeSymbol(function.getEntryPoint(), name, function.getParentNamespace());\n\t\t\tfunction.setName(name, source);\n\t\t}\n\t\tcatch (DuplicateNameException e) {\n\t\t\t// unexpected\n\t\t\tthrow new InvalidInputException(\n\t\t\t\t\"Function name conflict occurred when applying function signature.\");\n\t\t}\n\t}\n\n\t/**\n\t * The C language assumes array datatypes are passed simply as pointers (by reference) even though\n\t * other datatypes are passed by value.  This routine converts the datatype to the appropriate pointer\n\t * in situations where we need to get at the exact type being passed by \"value\"\n\t * @param dt the type\n\t * @param dtm the data type manager\n\t * @return the updated type\n\t */\n\tprivate static DataType settleCDataType(DataType dt, DataTypeManager dtm) {\n\t\tif (dt == null) {\n\t\t\treturn null;\n\t\t}\n\t\tDataType baseType = dt;\n\t\tif (baseType instanceof TypedefDataType) {","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/ApplyFunctionSignatureCmd.java#L380-L416","documentation":"Thrown by ApplyFunctionSignatureCmd.setName when function.setName raises DuplicateNameException. This happens when the target name already exists as a non-removable symbol in the same namespace (the command only removes a conflicting LABEL symbol first, not functions or other types). The DuplicateNameException is wrapped as InvalidInputException with this message.","triggerScenarios":"Applying a signature whose function name collides with an existing symbol in the same namespace that is not a label (e.g. another function, a class, a namespace). removeCodeSymbol only deletes a LABEL; any other SymbolType survives and setName then conflicts.","commonSituations":"Two functions sharing a name in the same namespace. Applying a signature that names a function identically to an existing class/namespace symbol. Importing a signature set with duplicate names.","solutions":["Rename or remove the conflicting non-label symbol in the namespace before applying the signature.","Use FunctionRenameOption.NO_CHANGE if you do not need to rename.","Namespace the new function differently so its name is unique.","Catch InvalidInputException, inspect the namespace, and resolve the collision manually."],"exampleFix":"// before\nnew ApplyFunctionSignatureCmd(entry, sig, source,\n    false, false, handler, FunctionRenameOption.RENAME_IF_DEFAULT).applyTo(program);\n// name collision with a non-label symbol -> InvalidInputException\n\n// after - choose a unique namespace or skip rename\nFunction f = program.getFunctionManager().getFunctionContaining(entry);\nNamespace ns = f.getParentNamespace();\nif (program.getSymbolTable().getSymbol(sig.getName(), f.getEntryPoint(), ns) != null\n    && /* not a label */) {\n    // skip rename: build sig with FunctionRenameOption.NO_CHANGE\n}\nnew ApplyFunctionSignatureCmd(entry, sig, source, false, false, handler,\n    FunctionRenameOption.NO_CHANGE).applyTo(program);","handlingStrategy":"validation","validationCode":"SymbolTable st = program.getSymbolTable();\nSymbol existing = st.getSymbol(name, function.getEntryPoint(), function.getParentNamespace());\nif (existing != null && existing.getSymbolType() != SymbolType.LABEL) {\n    // non-label collision - rename or use NO_CHANGE\n}","typeGuard":"boolean isNameAvailableForFunction(Program p, Function f, String name) {\n    Symbol s = p.getSymbolTable().getSymbol(name, f.getEntryPoint(), f.getParentNamespace());\n    return s == null || s.getSymbolType() == SymbolType.LABEL;\n}","tryCatchPattern":"try {\n    cmd.applyTo(program);\n} catch (Exception e) {\n    if (e.getMessage().contains(\"Function name conflict\")) {\n        // use FunctionRenameOption.NO_CHANGE or pick a unique name\n    } else throw e;\n}","preventionTips":["Check the namespace for non-label collisions before applying a signature.","Use FunctionRenameOption.NO_CHANGE when the rename is optional.","Namespace functions uniquely to avoid name clashes."],"tags":["function","signature","naming","command","symbol"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}