NationalSecurityAgency/ghidra · warning · IllegalArgumentException
Error parsing register=value string {part}
Error message
Error parsing register=value string {part} What it means
Thrown by FunctionStartRFParams.setRegistersAndValues(csv) when a comma-separated part does not split into exactly two segments on '='. The expected form is 'creg1=x,creg2=y'; a part with zero, or 2+, equals signs fails the regValPair.length != 2 check. Partial state is cleared before throwing.
Source
Thrown at Ghidra/Extensions/MachineLearning/src/main/java/ghidra/machinelearning/functionfinding/FunctionStartRFParams.java:193
}
/**
* Parses register,value pairs if the form creg1=x,creg2=from csv and stores them. Any
* existing register,value pairs are discarded.
*
* @param csv the list to parse
* @throws IllegalArgumentException if there are any parsing errors
*/
public void setRegistersAndValues(String csv) {
contextRegisterNames = new ArrayList<>();
contextRegisterVals = new ArrayList<>();
String[] parts = csv.split(",");
for (String part : parts) {
String[] regValPair = part.split("=");
if (regValPair.length != 2) {
contextRegisterNames.clear();
contextRegisterVals.clear();
throw new IllegalArgumentException("Error parsing register=value string " + part);
}
String regName = regValPair[0].trim();
if (trainingSource.getRegister(regName) == null) {
contextRegisterNames.clear();
contextRegisterVals.clear();
throw new IllegalArgumentException(
"Register " + regName + " not found for program " + trainingSource.getName());
}
contextRegisterNames.add(regName);
BigInteger bigInt = new BigInteger(regValPair[1].trim());
contextRegisterVals.add(bigInt);
}
}
/**
* Parses a CSV into a sorted list of distinct integer values (duplicates are ignored). Returns
* an empty list of a parse error is encountered.
* @param csv csv string to parseView on GitHub (pinned to d5f144c24d)
Solutions
- Format each element as <register>=<value>, e.g. 'cs=0x33,ds=0x2b'.
- Split on ',' first, then verify each element contains exactly one '=' before calling setRegistersAndValues.
- Strip stray commas/whitespace; ensure the value is a valid BigInteger literal (hex 0x.. or decimal).
Example fix
// before
params.setRegistersAndValues("cs:0x33, ds=0x2b"); // ':' instead of '='
// after
params.setRegistersAndValues("cs=0x33,ds=0x2b"); Defensive patterns
Strategy: validation
Validate before calling
public static boolean isValidRegValCsv(String csv) {
if (csv == null || csv.trim().isEmpty()) return true; // empty ok if optional
for (String part : csv.split(",")) {
String[] kv = part.split("=", -1);
if (kv.length != 2 || kv[0].trim().isEmpty() || kv[1].trim().isEmpty())
return false;
}
return true;
} Type guard
null
Try / catch
try {
params.setRegistersAndValues(csv);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Error parsing register=value string")) {
// re-prompt user with the correct <reg>=<val> format
} else throw e;
} Prevention
- Document the exact 'reg=value,reg=value' format next to the input field.
- Validate the CSV shape before passing it in.
- Trim whitespace around each token to avoid empty-name pitfalls.
When it happens
Trigger: setRegistersAndValues("eax,ebx=1") (missing '='), or "a==b" (extra '='), or a stray token like "," or whitespace-only segment; any malformed register=value CSV element.
Common situations: User typing context-register constraints in the Function Finder params dialog; a config string copy-pasted from a source that used a different separator (':' or space); trailing comma producing an empty segment.
Related errors
- Entry cannot be blank
- String must not begin or end with a comma
- Invalid element {part} - must be non-negative
- Register {regName} not found for program {programName}
- Maximum size of test sets must be positive!
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/70192862752f2767.
Report an issue: GitHub.