It was recently reported to the Debian rust team by the operators of Debian CI that after an update of rust-chrono, the test builtins::filters::common::tests::date_errors_on_incorrect_format in rust-tera was hanging with runaway memory use, until finally the process was killed by the OOM killer.
I dug into the code, and the hanging code was
let items: Vec<Item> =
StrftimeItems::new(&format).filter(|item| matches!(item, Item::Error)).collect();
if !items.is_empty() {
return Err(Error::msg(format!("Invalid date format `{}`", format)));
}
where "format" was "%2f"
Some digging revealed that the problem is that StrFtime was returning a never-ending iterator. I've filed a bug about this with rust-chrono
( chronotope/chrono#1725 ) but there doesn't seem to be any good reason for rust-tera to exhaust the iterator. It doesn't actually do anything with the collected list of errors.
So I've prepared a patch for rust-tera that avoids collecting the errors into a vec and instead makes it stop at the first error.
stop-at-first-error-from-StrftimeItems.diff.txt