{"record":{"id":"39f9f66a6ef0156e","repo":"NationalSecurityAgency/ghidra","slug":"could-not-recover-cached-scores-e-getmessage","errorCode":null,"errorMessage":"Could not recover cached scores: {e.getMessage()}","messagePattern":"Could not recover cached scores: (.+?)","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java","lineNumber":79,"sourceCode":"\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);\n\t\t\tif (val != null) {\n\t\t\t\treturn val.floatValue();\n\t\t\t}\n\t\t}\n\t\tthrow new LSHException(\"Self-score not recorded for \" + md5);\n\t}\n\n\t@Override\n\tpublic void commitSelfScore(String md5, float score) throws LSHException {\n\t\ttry {\n\t\t\tBufferedWriter writer = new BufferedWriter(new FileWriter(storageFile, true));\n\t\t\tif (cacheMap == null) {\n\t\t\t\twriter.write(Double.toString(simThreshold));\n\t\t\t\twriter.newLine();\n\t\t\t\twriter.write(Double.toString(sigThreshold));","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java#L61-L97","documentation":"Thrown by FileScoreCaching.getSelfScore() as a wrapper around any IOException emitted by loadCache(). This is the user-facing LSHException that surfaces cache-load failures (missing threshold lines, bad lines, unreadable file, permission errors) when a caller tries to look up a self-score by md5.","triggerScenarios":"Calling getSelfScore(md5) when the underlying cache file is corrupt, truncated, missing header lines, has a bad data line, or is unreadable due to I/O or permissions. The original IOException's message is appended for diagnostics.","commonSituations":"A score cache file got corrupted by a crashed run, manual editing, or a disk-full condition. Permissions on the cache file or directory prevent reading. The file is on a network mount that became unavailable.","solutions":["Inspect the wrapped IOException message (appended after the colon) to identify the root cause — it will be one of the specific loadCache errors.","Delete or reset the corrupt cache file via resetStorage(simThresh, sigThresh) and regenerate.","Verify filesystem permissions and that the cache path is accessible to the process."],"exampleFix":"// before\ntry {\n    float score = cache.getSelfScore(md5);\n} catch (LSHException e) {\n    // e.getMessage() == \"Could not recover cached scores: <ioMsg>\"\n}\n\n// after — reset and regenerate on cache corruption\ncatch (LSHException e) {\n    cache.resetStorage(simThresh, sigThresh);\n    // re-run scoring to repopulate, then retry\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate cache file integrity before querying scores\nFile cacheFile = new File(cachePath);\nif (cacheFile.exists() && cacheFile.length() < 10) {\n    cacheFile.delete(); // too small to be valid\n}","typeGuard":null,"tryCatchPattern":"try {\n    float score = cache.getSelfScore(md5);\n} catch (LSHException e) {\n    if (e.getMessage().startsWith(\"Could not recover\")) {\n        cache.resetStorage(simThresh, sigThresh);\n        // re-run scoring to repopulate, then retry\n    } else throw e;\n}","preventionTips":["Wrap getSelfScore in try-catch and reset the cache on load failures.","Log the wrapped IOException message to diagnose the root cause.","Validate cache file existence and size before heavy scoring operations."],"tags":["bsim","ghidra","score-cache","io","error-wrapping"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}