Yalantis/uCrop · error · CImgArgumentException

%s

Error message

%s

What it means

Inside CImg's fill() expression machinery, when the fill expression fails to parse as a valid value sequence and an earlier parse error message was captured (is_error_expr), the library rethrows that specific parser message verbatim as a CImgArgumentException, prefixed with the instance description (_cimg_instance).

Source

Thrown at ucrop/src/main/jni/CImg.h:35182

              }
#endif
            }
          }
          mp.end();

          if (result_end && mp.result_end) // Transfer result of the end() block if requested
            result_end->assign(mp.result_end + (mp.result_end_dim?1:0),std::max(1U,mp.result_end_dim));

          is_done = true;
        } catch (CImgException& e) { CImg<charT>::string(e._message).move_to(is_error_expr); }
      }

      // Try to fill values according to a value sequence.
      if (!is_done && mode&1) is_done = !_fill_from_values(expression,repeat_values);

      if (!is_done) {
        cimg::exception_mode(excmode);
        if (is_error_expr) throw CImgArgumentException(_cimg_instance
                                                       "%s",
                                                       cimg_instance,is_error_expr._data);
        else throw CImgArgumentException(_cimg_instance
                                         "%s(): Invalid sequence of filling values '%s'.",
                                         cimg_instance,calling_function,expression);
      }
      cimg::exception_mode(excmode);
      cimg_abort_test;
      return *this;
    }

    //! Fill sequentially pixel values according to a given expression \newinstance.
    CImg<T> get_fill(const char *const expression, const bool repeat_values, const bool allow_formula=true,
                     CImgList<T> *const list_images=0) const {
      return (+*this)._fill(expression,repeat_values,allow_formula?3:1,list_images,"fill",this,0);
    }

    //! Fill sequentially pixel values according to a value sequence, given as a string.

View on GitHub (pinned to f788b534b4)

Solutions

  1. Check the embedded message (it is substituted for %s) for the exact parser complaint and fix the expression syntax
  2. Validate expressions against CImg's fill() formula grammar before calling
  3. Test the expression on a tiny dummy image in a try/catch during development
  4. Sanitize/reject user-supplied expressions with a pre-parse validator

Example fix

// before
img.fill("x*y?%/2"); // malformed expression
// after
img.fill("x*y"); // valid fill expression
Defensive patterns

Strategy: try-catch

Try / catch

try { img.fill(expr.c_str()); } catch (CImgArgumentException& e) { /* e.what() embeds the parser message; log and reject expression */ }

Prevention

When it happens

Trigger: Calling fill("expression") where the expression is malformed such that the expression parser itself records an error string (is_error_expr non-empty) — e.g. invalid operators, bad variable names, or truncated formulas in the mini formula language.

Common situations: Typos in fill() math expressions; expressions copied from docs of a different CImg version; user-supplied expression strings passed through without validation; locale/whitespace issues breaking the parser.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/9c81f875504c923b. Report an issue: GitHub.