{"record":{"id":"97854868f857babf","repo":"NationalSecurityAgency/ghidra","slug":"cannot-have-signature-setting-of-0","errorCode":null,"errorMessage":"Cannot have signature setting of 0","messagePattern":"Cannot have signature setting of 0","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/GenSignatures.java","lineNumber":117,"sourceCode":"\n\tpublic void addFunctionTags(List<String> names) {\n\t\tif (names == null) {\n\t\t\treturn;\n\t\t}\n\t\tint flag = 1;\n\t\tflag <<= FunctionTagBSimFilterType.RESERVED_BITS;\t\t\t// The first bits are reserved\n\t\tfor (String name : names) {\n\t\t\tif ((flag == 0) || (!CategoryRecord.enforceTypeCharacters(name))) {\n\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t}\n\t\t\tattributes.put(name, flag);\n\t\t\tflag <<= 1;\n\t\t}\n\t}\n\n\tpublic void setVectorFactory(LSHVectorFactory vFactory) throws LSHException {\n\t\tif (vFactory.getSettings() == 0) {\n\t\t\tthrow new LSHException(\"Cannot have signature setting of 0\");\n\t\t}\n\t\tif (vectorFactory == vFactory) {\t// No change to factory\n\t\t\treturn;\n\t\t}\n\t\tif (manager != null) {\n\t\t\tmanager.clearFunctions();\t// Clear out cached signature as settings have changed\n\t\t}\n\t\tvectorFactory = vFactory;\n\t}\n\n\tpublic void addDateColumnName(String name) {\n\t\tif (name == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (!CategoryRecord.enforceTypeCharacters(name)) {\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t\tdateColumnName = name;","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/GenSignatures.java#L99-L135","documentation":"Thrown by GenSignatures.setVectorFactory when the provided LSHVectorFactory reports a settings value of 0 (vFactory.getSettings() == 0). The settings value encodes the signature-generation configuration (weights, hashing); zero means the factory was never properly initialized, so BSim refuses to use it to avoid generating unusable signatures.","triggerScenarios":"Calling genSignatures.setVectorFactory(factory) where factory.getSettings() returns 0. This happens when a WeightedLSHCosineVectorFactory is constructed but its settings were never loaded from a configuration/weight file.","commonSituations":"Creating a vector factory manually without loading weights/settings. Loading a configuration failed silently or was skipped before assigning the factory. Using a freshly-constructed factory that has not been initialized via the configuration template.","solutions":["Initialize the vector factory from a valid configuration before assigning it: load settings/weights so getSettings() is non-zero.","Use FunctionDatabase.generateLSHVectorFactory() plus a loaded Configuration to set up the factory properly.","Verify factory.getSettings() != 0 in a guard before calling setVectorFactory."],"exampleFix":"// before\nLSHVectorFactory factory = new WeightedLSHCosineVectorFactory(); // settings == 0\ngenSignatures.setVectorFactory(factory);\n// after\nWeightedLSHCosineVectorFactory factory = FunctionDatabase.generateLSHVectorFactory();\nfactory.setSettings(configuration); // loads non-zero settings\ngenSignatures.setVectorFactory(factory);","handlingStrategy":"validation","validationCode":"// Guard against a zero-settings vector factory\nLSHVectorFactory factory = FunctionDatabase.generateLSHVectorFactory();\n// ... initialize factory from a Configuration so settings are loaded ...\nif (factory.getSettings() == 0) {\n    throw new IllegalStateException(\n        \"Vector factory has settings == 0; configuration was not loaded\");\n}\ngenSignatures.setVectorFactory(factory);","typeGuard":null,"tryCatchPattern":"try {\n    genSignatures.setVectorFactory(factory);\n} catch (LSHException e) {\n    if (e.getMessage().contains(\"signature setting of 0\")) {\n        log.error(\"Vector factory not initialized; load a configuration first\", e);\n    }\n    throw e;\n}","preventionTips":["Always initialize the vector factory from a loaded Configuration before assigning it.","Assert factory.getSettings() != 0 in a helper that wires up GenSignatures.","Unit-test the factory initialization path so a regression that zeroes settings is caught."],"tags":["bsim","signature-settings","configuration","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}