{{ message }}
Fix PyDict REPL completion without GIL#772
Open
Beforerr wants to merge 1 commit into
Open
Conversation
748d38c to
5e41917
Compare
Member
5e41917 to
9b0f572
Compare
Author
|
Thanks, you were right. The original MWE was testing the wrong shape and I rewrote this to use the existing main-thread path instead. The only wrapped paths now are Checked with focused tests and a |
9b0f572 to
2e0bea9
Compare
Author
2e0bea9 to
3a17ba7
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.

Summary
In normal REPL operation, the main Python thread can still hold the GIL while Julia runs completion on an interactive/default thread. Dict-key completion then evaluates a
PyDictfrom that completion thread, which is not safe to call Python directly.This routes the Python-touching pieces through the existing main-thread machinery when needed:
keys(::PyDict)iteration used byREPL.REPLCompletions.find_dict_matchesshow(::Py), because completion callsrepr(key)and defaultPyDictkeys arePyIf the current task already owns the GIL, the call stays direct. Otherwise it dispatches to
C.on_main_thread.MWE
This reproduces the crash on
mainhere withjulia --project -t 2, reachingPyObject_GetIterfromiterate(::KeySet{<:PyDict})insideREPLCompletions.find_dict_matches.