NationalSecurityAgency/ghidra · warning · LSHException
Function tag already exists
Error message
Function tag already exists
What it means
Thrown by fdbInstallTag when query.tag_name already exists in info.functionTags. BSim prevents duplicate tag allocation since each tag occupies a fixed bitmask bit; duplicates would be ambiguous.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java:2232
public List<String> getFunctionTags() {
return info.functionTags;
}
/**
* Entry point for the InstallTagRequest command
* @param query the install query to execute
* @throws LSHException if the function tag already exists or is not valid
* @throws SQLException if there is an error issuing the query
*/
private void fdbInstallTag(InstallTagRequest query) throws LSHException, SQLException {
ResponseInfo response = query.installresponse;
if (!CategoryRecord.enforceTypeCharacters(query.tag_name)) {
throw new LSHException("Bad characters in proposed function tag");
}
// Check for existing tag
if (info.functionTags != null) {
if (info.functionTags.contains(query.tag_name)) {
throw new LSHException("Function tag already exists");
}
}
if (info.functionTags == null) {
info.functionTags = new ArrayList<>();
}
// There are only 32-bits of space in the function record reserved for storing the presence of tags
if (info.functionTags.size() >= FunctionTagBSimFilterType.MAX_TAG_COUNT) {
throw new LSHException(
"Cannot allocate new function tag: " + query.tag_name + " - Column space is full");
}
info.functionTags.add(query.tag_name);
keyValueTable.writeFunctionTags(info);
response.info = info;
}
/**
* Entry point for the InstallMetadataRequest command
* @param query the query to executeView on GitHub (pinned to d5f144c24d)
Solutions
- Pre-check info.functionTags for the tag name and skip if present.
- Make tag-installation code idempotent.
- Fetch current tags via QueryInfo before attempting installation.
Example fix
// before
db.execute(installTagReq); // may already exist
// after
if (info.functionTags == null || !info.functionTags.contains(req.tag_name)) {
db.execute(installTagReq);
} Defensive patterns
Strategy: validation
Validate before calling
List<String> existing = db.getDatabaseInformation().functionTags;
if (existing == null || !existing.contains(req.tag_name)) {
db.execute(req);
} Try / catch
catch (LSHException e) { if (e.getMessage().contains("already exists")) { /* benign on re-run */ } else throw e; } Prevention
- Pre-check existing tags before installing to keep scripts idempotent.
- Use QueryInfo to refresh the tag list in long-running clients.
When it happens
Trigger: Issuing an InstallTagRequest for a tag_name already present in the database's loaded functionTags list; re-running tag setup scripts without checking.
Common situations: Re-running initialization scripts; concurrent clients racing to install the same tag; migration/import tooling that doesn't first query existing tags.
Related errors
- Executable category already exists
- No thresholds have been established
- Cannot reset singled executable
- database in use
- Connection with database not established
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/ce2f574102270035.
Report an issue: GitHub.