{"record":{"id":"69abfde14d39d52a","repo":"NationalSecurityAgency/ghidra","slug":"cannot-reset-singled-executable","errorCode":null,"errorMessage":"Cannot reset singled executable","messagePattern":"Cannot reset singled executable","errorType":"validation","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableScorerSingle.java","lineNumber":58,"sourceCode":"\t * must be provided.\n\t * @param cache is the self-score cacher or null\n\t * @throws LSHException for problems initializing the cache\n\t */\n\tpublic ExecutableScorerSingle(ScoreCaching cache) throws LSHException {\n\t\tsuper();\t\t\t\t\t\t// Turn on single executable filtering\n\t\tsingleScore = null;\n\t\tscoreCache = cache;\n\t\tif (scoreCache == null) {\n\t\t\tscoreCache = new TemporaryScoreCaching();\n\t\t}\n\t\tsimThreshold = scoreCache.getSimThreshold();\n\t\tsigThreshold = scoreCache.getSigThreshold();\n\t}\n\n\t@Override\n\tpublic void setSingleExecutable(String md5) throws LSHException {\n\t\tif (singleExeXref >= 0) {\n\t\t\tthrow new LSHException(\"Cannot reset singled executable\");\n\t\t}\n\t\tsuper.setSingleExecutable(md5);\n\t}\n\n\t@Override\n\tpublic int countSelfScores() {\n\t\tIterator<ExecutableRecord> iter = executableSet.getExecutableRecordSet().iterator();\n\t\tint count = 0;\n\t\twhile (iter.hasNext()) {\n\t\t\tExecutableRecord exe = iter.next();\n\t\t\ttry {\n\t\t\t\tscoreCache.getSelfScore(exe.getMd5());\n\t\t\t\tcount += 1;\n\t\t\t}\n\t\t\tcatch (LSHException e) {\n\t\t\t\t// Don't increment count\n\t\t\t}\n\t\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableScorerSingle.java#L40-L76","documentation":"Thrown by ExecutableScorerSingle.setSingleExecutable() when singleExeXref is already >= 0, meaning a singled-out executable has already been established. ExecutableScorerSingle is designed for a one-to-many comparison where exactly one executable is the focus; the single is immutable once set because the scorer allocates a single-row score array and pairs functions relative to it.","triggerScenarios":"Calling setSingleExecutable(md5) a second time on the same ExecutableScorerSingle instance. The first successful call sets singleExeXref to a non-negative value; any subsequent call throws before reaching the superclass.","commonSituations":"Reusing an ExecutableScorerSingle instance across multiple queries (e.g. in a loop comparing different executables) without constructing a fresh scorer each iteration. Also occurs when merging two workflows that each set the single executable.","solutions":["Construct a new ExecutableScorerSingle instance for each new executable you want to compare.","Call resetStorage(simThresh, sigThresh) which nulls singleScore and resets the cache — but note this does NOT reset singleExeXref, so you still need a fresh instance.","Restructure your loop to create the scorer inside the loop body rather than reusing one outside."],"exampleFix":"// before\nExecutableScorerSingle scorer = new ExecutableScorerSingle(cache);\nfor (String md5 : md5List) {\n    scorer.setSingleExecutable(md5); // throws on 2nd iteration\n}\n\n// after\nfor (String md5 : md5List) {\n    ExecutableScorerSingle scorer = new ExecutableScorerSingle(cache);\n    scorer.setSingleExecutable(md5);\n}","handlingStrategy":"validation","validationCode":"// Check before calling (singleExeXref is protected; track externally)\nboolean alreadySet = (scorer.getSingleExeXref() >= 0); // if exposed\nif (!alreadySet) {\n    scorer.setSingleExecutable(md5);\n}","typeGuard":null,"tryCatchPattern":"try {\n    scorer.setSingleExecutable(md5);\n} catch (LSHException e) {\n    if (e.getMessage().contains(\"Cannot reset\")) {\n        // create a fresh scorer for the new executable\n        scorer = new ExecutableScorerSingle(cache);\n        scorer.setSingleExecutable(md5);\n    } else throw e;\n}","preventionTips":["Construct a new ExecutableScorerSingle for each executable comparison rather than reusing.","Track whether setSingleExecutable has been called in your own code.","Avoid sharing a single scorer across multiple comparison targets."],"tags":["bsim","ghidra","scorer","state","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}