Yalantis/uCrop · error · CImgArgumentException
[" cimg_appname "_math_parser] CImg<
Error message
[" cimg_appname "_math_parser] CImg<%s>::%s: %s%s Image list cannot be empty, for expression '%s'.
What it means
The math parser helper check_list throws when an expression function that operates on the image list (e.g. dynamic-array functions) is invoked while the parser's imglist is empty. CImg needs at least one image in the list to execute such functions. This prevents out-of-bounds access to a non-existent image slot.
Solutions
- Ensure the CImg/CImgList is assigned (non-empty) before evaluating the expression.
- Check that the image file load succeeded before running fill()/expression.
- Use an expression that does not require the image list if no images are needed.
- Guard with if (!img.is_empty()) before evaluating.
Example fix
// before
CImg<float> img; // empty
img.fill("da_at(I,0)");
// after
CImg<float> img(w,h,1,1,0);
img.fill("da_at(I,0)"); Defensive patterns
Strategy: validation
Validate before calling
if (img.is_empty()) throw std::runtime_error("image must be assigned before expression evaluation"); Type guard
bool usable(const CImg<T>& im) { return !im.is_empty() && im.width() > 0; } Try / catch
try { img.fill(expr); } catch (const cimg_library::CImgArgumentException& e) { /* assign image or skip */ } Prevention
- Always assign/construct images before fill()
- Check load() return state
- Skip list-dependent functions when no images exist
When it happens
Trigger: Calling a function like 'da_at(...)' or other image-list-dependent MP functions inside fill()/expression on a default-constructed or empty CImgList, or an expression evaluated without assigning images.
Common situations: Invoking expression functions on a CImg that has never been assigned data; passing an empty CImgList to the math parser; chaining operations after a failed load left the list empty.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- [" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- [" cimg_appname "_math_parser] CImg<
- [" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/22fe3240b418f639.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:25267
else cimg_snprintf(sb_type,sb_type._width,"'scalar' or 'vector'");
}
char *s0;
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s%s %s%s has invalid type '%s' (should be %s), "
"in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,*s_op?":":"",
s_arg,*s_op=='F'?(*s_arg?" argument":" Argument"):(*s_arg?" operand":" Operand"),
s_type(arg)._data,sb_type._data,s0);
}
}
// Check that imglist are not empty.
void check_list(char *const ss, char *const se, const char saved_char) {
if (!imglist) {
char *s0;
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s%s Image list cannot be empty, for expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,*s_op?":":"",s0);
}
}
static void mp_check_list(_cimg_math_parser& mp, const char *const funcname) {
if (!mp.imglist)
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>: Function '%s()': Images list cannot be empty.",
pixel_type(),funcname);
}
// Insert constant value in memory.
unsigned int const_scalar(const double val) {
// Search for built-in constant.
if (cimg::type<double>::is_nan(val)) return _cimg_mp_slot_nan;
if (val==(double)(int)val) {View on GitHub (pinned to f788b534b4)