Repository navigation
JuliaCall: lock the GIL when the IPython extension copies Julia output - #851
Open
MilesCranmerBot wants to merge 1 commit into
Open
MilesCranmerBot wants to merge 1 commit into
MilesCranmerBot wants to merge 1 commit into
Conversation
In Jupyter the extension copies Julia's stdout and stderr to Python from background tasks. If Julia printed while the GIL was unlocked, for example in `_jl_call_nogil`, those tasks called Python without the GIL and the process segfaulted (JuliaPy#542). Co-authored-by: Miles Cranmer <miles.cranmer@gmail.com>
This branch has not been deployed
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.
Why
In Jupyter, the JuliaCall IPython extension copies Julia's stdout and stderr to Python from two background tasks. These tasks call Python without the GIL if Julia prints while the GIL is unlocked, for example in
_jl_call_nogil, and the process segfaults. This is the first case in #542.What changed
Scope
_jl_call_nogilwith jupyter extension or passing pytypes #542. Passing Python objects to Julia code that uses them under_jl_call_nogilis still unsafe, as documented.Verification
test_ipython_output_nogilruns the extension with a kernel-like shell in a subprocess and prints from_jl_call_nogil. Without the fix the child segfaults (return code -11); with it, the output reaches Python'ssys.stdout.The same crash affects
seval(..., nogil=True)from #850.