{"record":{"id":"19cce746311942f0","repo":"NationalSecurityAgency/ghidra","slug":"bad-line-in-score-file","errorCode":null,"errorMessage":"Bad line in score file","messagePattern":"Bad line in score file","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java","lineNumber":64,"sourceCode":"\t\tBufferedReader reader = new BufferedReader(new FileReader(storageFile));\n\t\tString floatString = reader.readLine();\n\t\tif (floatString == null) {\n\t\t\treader.close();\n\t\t\tthrow new IOException(\"Score file missing threshold lines\");\n\t\t}\n\t\tsimThreshold = Float.parseFloat(floatString);\n\t\tfloatString = reader.readLine();\n\t\tif (floatString == null) {\n\t\t\treader.close();\n\t\t\tthrow new IOException(\"Score file missing threshold lines\");\n\t\t}\n\t\tsigThreshold = Float.parseFloat(floatString);\n\t\tfloatString = reader.readLine();\n\t\twhile (floatString != null) {\n\t\t\tString[] split = floatString.split(\" \");\n\t\t\tif (split.length != 2 || split[0].length() != 32) {\n\t\t\t\treader.close();\n\t\t\t\tthrow new IOException(\"Bad line in score file\");\n\t\t\t}\n\t\t\tfloat val = Float.parseFloat(split[1]);\n\t\t\tcacheMap.put(split[0], val);\n\t\t\tfloatString = reader.readLine();\n\t\t}\n\t\treader.close();\n\t}\n\n\t@Override\n\tpublic float getSelfScore(String md5) throws LSHException {\n\t\ttry {\n\t\t\tloadCache();\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new LSHException(\"Could not recover cached scores: \" + e.getMessage());\n\t\t}\n\t\tif (cacheMap != null) {\n\t\t\tFloat val = cacheMap.get(md5);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java#L46-L82","documentation":"Thrown by FileScoreCaching.loadCache() when a score entry line (after the two threshold headers) does not conform to the expected format: exactly two space-separated tokens where the first token is a 32-character md5 string and the second is a float. Any line failing split.length != 2 or split[0].length() != 32 triggers this.","triggerScenarios":"Loading a cache file where a data line is malformed — e.g. a tab instead of a space delimiter, a truncated md5, extra whitespace producing more than 2 split tokens, a non-numeric score value, or a blank line in the middle of the data section.","commonSituations":"The cache file was hand-edited or generated by a different tool. A filesystem encoding issue or line-ending mismatch (CRLF vs LF) corrupted the split. An older BSim version wrote a different format that is now incompatible.","solutions":["Delete the cache file and regenerate it by running the scoring workflow that commits self-scores.","Call resetStorage(simThresh, sigThresh) to wipe and reinitialize.","If you must repair, verify each data line is \"<32-char-md5> <float>\" with a single space separator and LF line endings."],"exampleFix":"// before — cache file has a bad line: \"abc123 0.75\" (md5 too short)\nFileScoreCaching cache = new FileScoreCaching(path);\ncache.getSelfScore(md5); // throws \"Bad line in score file\"\n\n// after\nnew File(path).delete(); // or cache.resetStorage(simThresh, sigThresh)\n// re-run the ingest that populates self-scores","handlingStrategy":"validation","validationCode":"File cacheFile = new File(cachePath);\nif (cacheFile.exists()) {\n    try (BufferedReader r = new BufferedReader(new FileReader(cacheFile))) {\n        r.readLine(); r.readLine(); // skip thresholds\n        String line;\n        while ((line = r.readLine()) != null) {\n            String[] parts = line.split(\" \");\n            if (parts.length != 2 || parts[0].length() != 32) {\n                cacheFile.delete(); // malformed\n                break;\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    cache.getSelfScore(md5);\n} catch (LSHException e) {\n    if (e.getMessage().contains(\"Bad line\")) {\n        cache.resetStorage(simThresh, sigThresh);\n    } else throw e;\n}","preventionTips":["Never hand-edit the score cache file; let the library manage it.","Validate each data line format if you must inspect the file.","Regenerate the cache from scratch when format errors appear."],"tags":["bsim","ghidra","score-cache","file-format","corruption"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}