From 4ca3139c0dd2d3a7ff47e8bf7dbaae8eee2d60c4 Mon Sep 17 00:00:00 2001 From: cjwcommuny Date: Tue, 11 Oct 2022 14:57:58 +0800 Subject: [PATCH 1/3] time: panic in release mode when `mark_pending` called when the timer entry is deregistered or in pending fire --- tokio/src/runtime/time/entry.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index 2f36d46e0ed..bc92b2cc7e5 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -172,7 +172,9 @@ 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 deregistered or in pending fire"); if cur_state > not_after { break Err(cur_state); From 1a933ae537f23e871ed92634a04eb6f21c4dbd59 Mon Sep 17 00:00:00 2001 From: cjwcommuny Date: Tue, 11 Oct 2022 15:36:48 +0800 Subject: [PATCH 2/3] fix fmt --- tokio/src/runtime/time/entry.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index bc92b2cc7e5..bf716a02888 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -174,7 +174,10 @@ impl StateCell { loop { // 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 deregistered or in pending fire"); + assert!( + cur_state < STATE_MIN_VALUE, + "mark_pending called when the timer entry is deregistered or in pending fire" + ); if cur_state > not_after { break Err(cur_state); From 04a615d0a04a1312208165e58b9114e3e853c163 Mon Sep 17 00:00:00 2001 From: cjw Date: Sun, 16 Oct 2022 11:47:55 +0800 Subject: [PATCH 3/3] update error message --- tokio/src/runtime/time/entry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio/src/runtime/time/entry.rs b/tokio/src/runtime/time/entry.rs index bf716a02888..c4c4ba1b775 100644 --- a/tokio/src/runtime/time/entry.rs +++ b/tokio/src/runtime/time/entry.rs @@ -176,7 +176,7 @@ impl StateCell { // https://github.com/tokio-rs/tokio/issues/3675 assert!( cur_state < STATE_MIN_VALUE, - "mark_pending called when the timer entry is deregistered or in pending fire" + "mark_pending called when the timer entry is in an invalid state" ); if cur_state > not_after {