Repository navigation
time: drop timer lock before dropping waker in clear_entry - #8552
Merged
Merged
Conversation
When cancelling a timer in `Handle::clear_entry`, `TimerHandle::fire` returns the previously registered `Option<Waker>`. Previously, that temporary was dropped before `lock` went out of scope, running the waker's destructor while still holding the timer driver mutex. If the waker's `Drop` implementation drops or resets another registered `Sleep` on the same runtime, it attempts to lock the timer driver mutex again and deadlocks. Explicitly drop the driver lock before dropping the returned waker. Fixes: tokio-rs#8551
ADD-SP
approved these changes
Oct 2, 2026
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When cancelling a timer in
Handle::clear_entry,TimerHandle::firereturns the previously registered
Option<Waker>. Previously, thattemporary was dropped before
lockwent out of scope, running thewaker's destructor while still holding the timer driver mutex. If the
waker's
Dropimplementation drops or resets another registeredSleepon the same runtime, it attempts to lock the timer driver mutex again
and deadlocks.
Explicitly drop the driver lock before dropping the returned waker.
Fixes: #8551