From 00082c668fefdba8a373720b54adfbbe514b7196 Mon Sep 17 00:00:00 2001 From: cjw Date: Sun, 16 Oct 2022 14:46:57 +0800 Subject: [PATCH] time: panic in release mode when `mark_pending` called illegally (#5093) --- tokio/src/runtime/time/entry.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index 2f36d46e0ed..c4c4ba1b775 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -172,7 +172,12 @@ impl StateCell { let mut cur_state = self.state.load(Ordering::Relaxed); loop { - debug_assert!(cur_state < STATE_MIN_VALUE); + // improve the error message for things like + // https://github.com/tokio-rs/tokio/issues/3675 + assert!( + cur_state < STATE_MIN_VALUE, + "mark_pending called when the timer entry is in an invalid state" + ); if cur_state > not_after { break Err(cur_state);