{"record":{"id":"952980255b2f4090","repo":"NationalSecurityAgency/ghidra","slug":"could-not-commit-self-score-ex-getmessage","errorCode":null,"errorMessage":"Could not commit self-score: {ex.getMessage()}","messagePattern":"Could not commit self-score: (.+?)","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java","lineNumber":109,"sourceCode":"\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));\n\t\t\t\twriter.newLine();\n\t\t\t\tcacheMap = new TreeMap<String, Float>();\n\t\t\t}\n\t\t\tcacheMap.put(md5, score);\n\t\t\twriter.write(md5);\n\t\t\twriter.append(' ');\n\t\t\twriter.write(Float.toString(score));\n\t\t\twriter.newLine();\n\t\t\twriter.close();\n\t\t}\n\t\tcatch (IOException ex) {\n\t\t\tthrow new LSHException(\"Could not commit self-score: \" + ex.getMessage());\n\t\t}\n\t}\n\n\t@Override\n\tpublic double getSimThreshold() throws LSHException {\n\t\ttry {\n\t\t\tloadCache();\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new LSHException(\"Problems loading score cache: \" + e.getMessage());\n\t\t}\n\t\treturn simThreshold;\n\t}\n\n\t@Override\n\tpublic double getSigThreshold() throws LSHException {\n\t\ttry {\n\t\t\tloadCache();","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/FileScoreCaching.java#L91-L127","documentation":"Thrown by FileScoreCaching.commitSelfScore() wrapping any IOException that occurs while appending a score entry to the cache file. The write opens the file in append mode (FileWriter with append=true); if the I/O operation fails the exception is wrapped in an LSHException with the original message appended.","triggerScenarios":"Calling commitSelfScore(md5, score) when the cache file path is not writable, the parent directory does not exist, the disk is full, the file is locked by another process, or the path points to a directory rather than a file.","commonSituations":"The cache file directory was never created. Permissions deny write access. A disk-full or quota-exceeded condition. The path resolves to a read-only filesystem or a location the JVM cannot open in append mode.","solutions":["Verify the parent directory of the cache file exists and is writable by the process.","Check the wrapped IOException message for the specific OS-level cause (permission denied, no space, etc.).","Ensure no other process holds an exclusive lock on the cache file."],"exampleFix":"// before — cache path parent dir does not exist\nFileScoreCaching cache = new FileScoreCaching(\"/nonexistent/scores.txt\");\ncache.commitSelfScore(md5, 42.0f); // throws \"Could not commit self-score: ...\"\n\n// after — ensure parent directory\nFile cacheFile = new File(cachePath);\ncacheFile.getParentFile().mkdirs();\nFileScoreCaching cache = new FileScoreCaching(cachePath);\ncache.commitSelfScore(md5, 42.0f);","handlingStrategy":"validation","validationCode":"File cacheFile = new File(cachePath);\nFile parent = cacheFile.getParentFile();\nif (parent != null && !parent.exists()) {\n    parent.mkdirs();\n}\nif (cacheFile.exists() && !cacheFile.canWrite()) {\n    throw new IllegalStateException(\"Cache file not writable: \" + cachePath);\n}","typeGuard":null,"tryCatchPattern":"try {\n    cache.commitSelfScore(md5, score);\n} catch (LSHException e) {\n    if (e.getMessage().startsWith(\"Could not commit\")) {\n        // check disk space, permissions, path validity\n        throw new RuntimeException(\"Cache write failed: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Ensure the cache file's parent directory exists and is writable.","Check disk space before large ingest operations.","Avoid pointing the cache path at a read-only location."],"tags":["bsim","ghidra","score-cache","io","permissions"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}