You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Meta-Issue: Mutli-threading leads to segfaults #1096
This seems to be coming up quite often, in order to track this issue I took the liberty to create this meta-issue linking all other related issues I could find:
using Base.Threads
using PyCall
o =PyObject(randn(3,3))
t = Threads.@spawnbeginprintln(Core.stderr, propertynames(o))
endwait(t)
$ julia +1.12 --project=. mwe.jl[119772] signal 11 (1): Segmentation faultin expression starting at /home/topolarity/repos/claude/PyCall.jl/mwe.jl:7_PyType_Lookup at /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0 (unknown line)_PyObject_LookupSpecial at /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0 (unknown line)PyObject_Dir at /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0 (unknown line)
Looks like they opt to leave the GIL-management to users for most of the API. For propertynames (which is called by the REPL tab-complete), they provide a mechanism to request execution on the main thread.
This is now causing significant problem whenever I want to use PyPlot on a new computer. There doesn't seem to be any alternative proposed here other than #1097. Given that it is relatively low impact on the user API (I've used the rebased version for a new months now) I'd like to just merge it soon. If there's a better approach we can switch the implementation later. I don't think this would cause any more of an API breakage since even if the new/final approach require changes in the user code, those code are already broken as of now and people have already been assuming that it works.
Activity
axsk commentedon Jan 22, 2026
Seeing that the last change to this repo is older then two years, is it correct to assume it has become unmaintained and no fix is to be expected?
topolarity commentedon Mar 10, 2026
Reproducer:
The issue seems to be that PyCall.jl does not manage thread states or the GIL: https://docs.python.org/3/c-api/threads.html
Here's a "fixed" version of the example:
topolarity commentedon Mar 10, 2026
Equivalent fix in PythonCall.jl: JuliaPy/PythonCall.jl#677
Looks like they opt to leave the GIL-management to users for most of the API. For
propertynames(which is called by the REPL tab-complete), they provide a mechanism to request execution on the main thread.yuyichao commentedon Oct 2, 2026
This is now causing significant problem whenever I want to use PyPlot on a new computer. There doesn't seem to be any alternative proposed here other than #1097. Given that it is relatively low impact on the user API (I've used the rebased version for a new months now) I'd like to just merge it soon. If there's a better approach we can switch the implementation later. I don't think this would cause any more of an API breakage since even if the new/final approach require changes in the user code, those code are already broken as of now and people have already been assuming that it works.