{"record":{"id":"7d7f7aab4ac6dcdb","repo":"NationalSecurityAgency/ghidra","slug":"register-regname-not-found-for-program-programn","errorCode":null,"errorMessage":"Register {regName} not found for program {programName}","messagePattern":"Register (.+?) not found for program (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Extensions/MachineLearning/src/main/java/ghidra/machinelearning/functionfinding/FunctionStartRFParams.java","lineNumber":199,"sourceCode":"\t * @param csv the list to parse\n\t * @throws IllegalArgumentException if there are any parsing errors\n\t */\n\tpublic void setRegistersAndValues(String csv) {\n\t\tcontextRegisterNames = new ArrayList<>();\n\t\tcontextRegisterVals = new ArrayList<>();\n\t\tString[] parts = csv.split(\",\");\n\t\tfor (String part : parts) {\n\t\t\tString[] regValPair = part.split(\"=\");\n\t\t\tif (regValPair.length != 2) {\n\t\t\t\tcontextRegisterNames.clear();\n\t\t\t\tcontextRegisterVals.clear();\n\t\t\t\tthrow new IllegalArgumentException(\"Error parsing register=value string \" + part);\n\t\t\t}\n\t\t\tString regName = regValPair[0].trim();\n\t\t\tif (trainingSource.getRegister(regName) == null) {\n\t\t\t\tcontextRegisterNames.clear();\n\t\t\t\tcontextRegisterVals.clear();\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Register \" + regName + \" not found for program \" + trainingSource.getName());\n\t\t\t}\n\t\t\tcontextRegisterNames.add(regName);\n\t\t\tBigInteger bigInt = new BigInteger(regValPair[1].trim());\n\t\t\tcontextRegisterVals.add(bigInt);\n\t\t}\n\t}\n\n\t/**\n\t * Parses a CSV into a sorted list of distinct integer values (duplicates are ignored).  Returns\n\t * an empty list of a parse error is encountered.\n\t * @param csv csv string to parse\n\t * @return sorted list  \n\t */\n\tpublic static List<Integer> parseIntegerCSV(String csv) {\n\t\tif (StringUtils.isBlank(csv)) {\n\t\t\tthrow new IllegalArgumentException(\"Entry cannot be blank\");\n\t\t}","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Extensions/MachineLearning/src/main/java/ghidra/machinelearning/functionfinding/FunctionStartRFParams.java#L181-L217","documentation":"Thrown by FunctionStartRFParams.setRegistersAndValues(csv) when a register name parsed from the CSV is not present in the training source program — trainingSource.getRegister(regName) returned null. The register must be a real context register defined in the program's language for it to be constrainable. State is cleared before throwing.","triggerScenarios":"Passing a register name that does not exist for the program's language (e.g. 'rax' for an ARM program, or a typo), or a context register that the Sleigh language does not expose.","commonSituations":"Copying register constraints from a different architecture; mistyping a register; using a processor context register that the language marks as hidden/unnamed.","solutions":["Use program.getLanguage().getRegisters() (or getRegister(name)) to enumerate valid register names for the training program and pass only those.","Correct the spelling/architecture of the register name in the CSV.","If the register should exist, verify the correct language/program is the trainingSource."],"exampleFix":"// before\nparams.setRegistersAndValues(\"rax=0\"); // ARM program\n\n// after\nRegister r = trainingSource.getRegister(\"r0\");\nparams.setRegistersAndValues(r == null ? \"\" : \"r0=0\");","handlingStrategy":"validation","validationCode":"import ghidra.program.model.listing.Program;\nString csv = \"cs=0x33,ds=0x2b\";\nStringBuilder ok = new StringBuilder();\nfor (String part : csv.split(\",\")) {\n    String[] kv = part.split(\"=\", -1);\n    String reg = kv[0].trim();\n    if (trainingSource.getRegister(reg) != null) {\n        if (ok.length() > 0) ok.append(\",\");\n        ok.append(part);\n    } // else skip unknown register\n}\nparams.setRegistersAndValues(ok.toString());","typeGuard":"null","tryCatchPattern":"try {\n    params.setRegistersAndValues(csv);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"not found for program\")) {\n        // fetch valid registers from trainingSource and re-prompt\n    } else throw e;\n}","preventionTips":["Derive register-name options from trainingSource.getLanguage().getRegisters().","Do not copy architecture-specific register constraints across programs.","Validate each name via program.getRegister(name) before building the CSV."],"tags":["machine-learning","validation","register-lookup","function-finder"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}