From f7c67b8609143caa3c033a269d8d084c180cb45a Mon Sep 17 00:00:00 2001 From: A386official Date: Sat, 28 Feb 2026 09:35:34 +0000 Subject: [PATCH 1/2] fix(cranelift): use saturating_sub in PassTimes::total to prevent panic PassTimes::total() subtracts child duration from total duration using the `-` operator, which panics on underflow. When timing tokens are dropped out of order (possible in release builds where the debug_assert in Drop is elided), child can exceed total, causing: "overflow when subtracting durations" The Display impl already handles this correctly using checked_sub. Use saturating_sub in total() for consistency and to prevent the panic in production. Fixes #12692 --- cranelift/codegen/src/timing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cranelift/codegen/src/timing.rs b/cranelift/codegen/src/timing.rs index a06c6001ef41..5b42b69d43ef 100644 --- a/cranelift/codegen/src/timing.rs +++ b/cranelift/codegen/src/timing.rs @@ -171,7 +171,7 @@ mod enabled { /// Returns the total amount of time taken by all the passes measured. pub fn total(&self) -> Duration { - self.pass.iter().map(|p| p.total - p.child).sum() + self.pass.iter().map(|p| p.total.saturating_sub(p.child)).sum() } } From cebf849bcdc62d088bdfc716389aa8cfe2155719 Mon Sep 17 00:00:00 2001 From: A386official Date: Sat, 28 Feb 2026 09:46:43 +0000 Subject: [PATCH 2/2] style: fix rustfmt formatting Break method chain across multiple lines to satisfy rustfmt's line length requirements. Signed-off-by: A386official --- cranelift/codegen/src/timing.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cranelift/codegen/src/timing.rs b/cranelift/codegen/src/timing.rs index 5b42b69d43ef..8eb4630ba0ec 100644 --- a/cranelift/codegen/src/timing.rs +++ b/cranelift/codegen/src/timing.rs @@ -171,7 +171,10 @@ mod enabled { /// Returns the total amount of time taken by all the passes measured. pub fn total(&self) -> Duration { - self.pass.iter().map(|p| p.total.saturating_sub(p.child)).sum() + self.pass + .iter() + .map(|p| p.total.saturating_sub(p.child)) + .sum() } }