Fix deadlock when dropping a Context while the runtime lock is held - #724
Merged
richarddd merged 8 commits intoSep 4, 2026
Merged
Conversation
Release 0.13.0
Release 0.12.2
richarddd
force-pushed
the
fix/parallel-try-lock-deadlock
branch
3 times, most recently
from
August 9, 2026 17:22
e61c85c to
d5c5192
Compare
Collaborator
Author
|
@DelSkayn would like your eyes on this one if possible |
richarddd
force-pushed
the
fix/parallel-try-lock-deadlock
branch
from
August 9, 2026 17:30
d5c5192 to
4e9f2e7
Compare
Sytten
approved these changes
Aug 28, 2026
Sytten
left a comment
Collaborator
There was a problem hiding this comment.
To the best of my ability this is good, but see my comments please
Comment on lines
+144
to
+146
| if let Ok(mut queued) = self.0.lock() { | ||
| queued.push(CtxPtr(ctx)); | ||
| } |
Collaborator
There was a problem hiding this comment.
No a fan of hiding a poison lock
Collaborator
Author
There was a problem hiding this comment.
Swapped it for an mpsc channel, so there's no lock to poison.
…hared by RawRuntime, unifying the sync and async drop-context parking paths.
richarddd
force-pushed
the
fix/parallel-try-lock-deadlock
branch
from
September 3, 2026 18:11
cef2767 to
41d05f9
Compare
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.
Mut::try_lock calls the blocking lock under the parallel feature, so dropping a Context while the same thread already holds the runtime lock deadlocks.
Track the locks held per thread so drop_context can free directly when it is already on that thread, and leave genuine cross-thread contention blocking as before.
Reachable without any explicit nested drop: a JsClass holding a Context deadlocks when its finalizer runs inside
with. Works without the parallel feature, hangs with it.