From de6f2902b53e7ddc19a021c9b85fa7bd7fd56630 Mon Sep 17 00:00:00 2001 From: Jacob Trueb Date: Sun, 29 Oct 2023 15:00:29 -0500 Subject: [PATCH] Prevent recursive AlreadyEncountered error formatting --- crates/polars-plan/src/logical_plan/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/polars-plan/src/logical_plan/mod.rs b/crates/polars-plan/src/logical_plan/mod.rs index d394327e41f43..045cd086ad792 100644 --- a/crates/polars-plan/src/logical_plan/mod.rs +++ b/crates/polars-plan/src/logical_plan/mod.rs @@ -79,7 +79,12 @@ impl std::fmt::Display for ErrorState { match self { ErrorState::NotYetEncountered { err } => write!(f, "NotYetEncountered({err})")?, ErrorState::AlreadyEncountered { prev_err_msg } => { - write!(f, "AlreadyEncountered({prev_err_msg})")? + if prev_err_msg.contains("AlreadyEncountered") { + // Recurively formatting error messages leads to N! memory usage + write!(f, "Multiple AlreadyEncountered")? + } else { + write!(f, "AlreadyEncountered({prev_err_msg})")? + } }, };