NationalSecurityAgency/ghidra · error · LSHException

Unable to parse configuration template

Error message

Unable to parse configuration template

What it means

Thrown by FunctionDatabase.loadConfigurationTemplate when the configuration template file exists but is not well-formed XML (SAXException). The template is parsed as XML to define signature weights and categories; a parse failure means the template is corrupt or malformed.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java:318

		}
		return res;
	}

	public static Configuration loadConfigurationTemplate(String configname) throws LSHException {
		ResourceFile moduleDataSubDirectory;
		final Configuration config = new Configuration();
		try {
			moduleDataSubDirectory = Application.getModuleDataSubDirectory("");
			config.loadTemplate(moduleDataSubDirectory, configname);
		}
		catch (final FileNotFoundException e) {
			throw new LSHException("Missing configuration data: " + e.getMessage());
		}
		catch (final IOException e) {
			throw new LSHException("Could open module data directory");
		}
		catch (final SAXException e) {
			throw new LSHException("Unable to parse configuration template");
		}
		return config;
	}

	/**
	 * Central location for building vector factory used by FunctionDatabase
	 * @return the LSHVectorFactory object
	 */
	public static WeightedLSHCosineVectorFactory generateLSHVectorFactory() {
		return new WeightedLSHCosineVectorFactory();
	}

	/**
	 * Get the maximum number of functions to be queried per staged query when searching
	 * for similar functions.
	 * @return maximum number of functions to be queried per staged query, or 0 for default
	 * which is generally ten (10) per stage.  See {@link SFQueryInfo#DEFAULT_QUERIES_PER_STAGE}.
	 */

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Validate the template file as well-formed XML using an XML linter or xmllint.
  2. Restore the template from the original Ghidra distribution if it was edited or corrupted.
  3. If using a custom template, ensure it matches the BSim configuration XML schema and all tags are properly closed.
  4. Check for encoding issues (open and re-save as UTF-8 without BOM).
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the template is well-formed XML before passing to BSim (best-effort)
ResourceFile dir = Application.getModuleDataSubDirectory("");
ResourceFile template = new ResourceFile(dir, configname);
try (InputStream in = template.getInputStream()) {
    javax.xml.parsers.DocumentBuilderFactory.newInstance()
        .newDocumentBuilder().parse(in); // throws if malformed
} catch (Exception xmlEx) {
    throw new IllegalArgumentException("Template is not well-formed XML: " + xmlEx.getMessage());
}
Configuration config = FunctionDatabase.loadConfigurationTemplate(configname);

Try / catch

try {
    Configuration config = FunctionDatabase.loadConfigurationTemplate(configname);
} catch (LSHException e) {
    if (e.getMessage().equals("Unable to parse configuration template")) {
        log.error("BSim config template '{}' is malformed XML", configname, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: config.loadTemplate encounters a SAXException while parsing the template file: unclosed tags, invalid characters, encoding mismatch, or structurally invalid XML.

Common situations: The template file was hand-edited and broken (unclosed tag, stray character). The file was transferred with a text mode that corrupted encoding/BOM. A partial write left a truncated XML file. A third-party or custom template does not conform to the expected schema.

Understand the failure class

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/839eac86af334f36. Report an issue: GitHub.