Yalantis/uCrop · error · CImgArgumentException
[cimg_appname_math_parser] CImg<%s>::%s: %s: %s name specifi
Error message
[cimg_appname_math_parser] CImg<%s>::%s: %s: %s name specified for argument %u when defining macro '%s()', in expression '%s'.
What it means
When defining a macro, each argument name in the formal parameter list must be a valid, non-empty identifier. If an argument name is empty or contains invalid characters (e.g. starts with '.'), the math parser throws this error at macro-definition compile time.
Source
Thrown at ucrop/src/main/jni/CImg.h:18608
pixel_type(),_cimg_mp_calling_function,s_op,
variable_name._data,s0);
}
while (*s && cimg::is_blank(*s)) ++s;
if (*s==')' && p1==1) break; // Function has no arguments
s2 = s; // Start of the argument name
is_sth = true; // is_valid_argument_name?
if (*s2>='0' && *s2<='9') is_sth = false;
else for (ns = s2; ns<s1 && *ns!=',' && *ns!='.' && !cimg::is_blank(*ns); ++ns)
if (!cimg::is_varchar(*ns)) { is_sth = false; break; }
s3 = ns; // End of the argument name
if (is_sth && ns>s2 && *ns=='.' && ns[1]=='.' && ns[2]=='.') { is_variadic = true; ns+=3; }
else if (*ns=='.') is_sth = false;
while (*ns && cimg::is_blank(*ns)) ++ns;
if (!is_sth || s2==s3 || (*ns!=',' && ns!=s1)) {
cimg::strellipsize(variable_name,64);
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: %s name specified for argument %u when defining "
"macro '%s()', in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,
is_sth?"Empty":"Invalid",p1,
variable_name._data,s0);
}
if (ns==s1 || *ns==',' || (is_variadic && *ns=='.')) { // New argument found
*s3 = 0;
p2 = (unsigned int)(s3 - s2); // Argument length
for (ps = std::strstr(macro_body[0],s2); ps; ps = std::strstr(ps,s2)) { // Replace by arg number
if (!((ps>macro_body[0]._data && cimg::is_varchar(*(ps - 1))) ||
(ps + p2<macro_body[0].end() && cimg::is_varchar(*(ps + p2))))) {
if (ps>macro_body[0]._data && *(ps - 1)=='#') { // Remove pre-number sign
*(ps - 1) = (char)p1;
if (ps + p2<macro_body[0].end() && *(ps + p2)=='#') { // Has pre & post number signs
std::memmove(ps,ps + p2 + 1,macro_body[0].end() - ps - p2 - 1);
macro_body[0]._width-=p2 + 1;View on GitHub (pinned to f788b534b4)
Solutions
- Give every macro argument a valid non-empty identifier (letters/digits/underscore)
- Remove stray commas, dots or whitespace artifacts from the parameter list
- Print the full expression before passing it to the parser to spot the malformed definition
Example fix
// before myfunc(,b) = a+b; // after myfunc(a,b) = a+b;
Defensive patterns
Strategy: validation
Validate before calling
function checkMacroParamNames(expr) {
const m = expr.match(/^\s*\w+\s*\(([^)]*)\)\s*=/);
if (!m) return true;
const ident = /^[A-Za-z_]\w*$/;
return m[1].split(',').every(p => ident.test(p.trim()));
}
Try / catch
try {
img.evaluate(expr);
} catch (e) {
if (/name specified for argument/.test(String(e))) {
// log expr and fix malformed parameter list
} else throw e;
}
Prevention
- Validate parameter identifiers with a regex before evaluation
- Avoid programmatic string building of parameter lists; use templates
- Trim whitespace and strip stray separators from generated definitions
When it happens
Trigger: Declaring a macro like 'f(,x)=...' (empty name), 'f(x.,y)=...' or 'f(.a)=...' (invalid identifier characters) so that is_sth is false or s2==s3 or the character after the name is not ','.
Common situations: Typos in macro definitions, programmatic generation of macro strings with malformed parameter lists, stray separators or dots in argument names.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Too much specif
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Invalid assignm
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Invalid %slvalu
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Array brackets
- [cimg_appname_math_parser] CImg<%s>::%s: Out-of-bounds refer
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/369dd9df56d04f4c.
Report an issue: GitHub.