-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix dead-lock in WeakKeyDict #33756
Closed
Closed
fix dead-lock in WeakKeyDict #33756
Conversation
This file contains 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
The command `x = WeakKeyDict(:a => 4)` followed by `push!(x, :b => 2)` gives a deadlock. The reason is a `lock` command in the iterate! method where the registered finalizer function with `unlock` never got called.
vtjnash
added a commit
that referenced
this pull request
Nov 12, 2019
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch>
Thanks! Sorry it's taken me so long to get back to you on this. I think this would have made sense, but that we can actually now just delete this gc-token. I've created a PR for that in #33825 and listed you as the co-author. |
Thanks a lot for fixing! -- Next time will probably just submit an issue/bug report in cases like this (where I don't too well understand what is going on;) |
vtjnash
added a commit
that referenced
this pull request
Nov 13, 2019
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch>
JeffBezanson
pushed a commit
that referenced
this pull request
Nov 13, 2019
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch> (cherry picked from commit 1731d0a)
KristofferC
pushed a commit
that referenced
this pull request
Dec 3, 2019
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch> (cherry picked from commit 1731d0a)
KristofferC
pushed a commit
that referenced
this pull request
Feb 20, 2020
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch> (cherry picked from commit 1731d0a)
KristofferC
pushed a commit
that referenced
this pull request
Feb 20, 2020
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch> (cherry picked from commit 1731d0a)
KristofferC
pushed a commit
that referenced
this pull request
Feb 22, 2020
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch> (cherry picked from commit 1731d0a)
KristofferC
pushed a commit
that referenced
this pull request
Apr 11, 2020
This was a hold-over from the old iteration protocol, which needed to maintain state between `done` and `next`. The `iteration` function of `Dict` has since been re-written to be safe for concurrent deletions. Replaces: #33756 Co-Authored-By: Hans-Peter Suter <hps@treetron.ch>
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.
In Julia version v1.3.0-rc4 and v1.4.0-DEV.427 the following commands give a dead-lock:
It is caused by a
lock
initerate(t::WeakKeyDict{K,V}) ..
where the finalizer withunlock
never gets called. The WeakKeyDict normally uses another task than the REPL; now when the terminal prints the wkd object, it uses the REPL task for the iterate! method and doesn't unlock it. Next time the WeakKeyDict does something, the object lock is 'locked_by' another task and the dict has to wait (forever...).I'm not sure about my fix. I supposed that the iterate! methods should be protected but I don't understand the 'no keys will be deleted' remark. Please review. I would have a branch with nicely formatted log messages upon interest. Also I can add tests when it is clear how the fix will look like.