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
propertynames segfaults when called inside PythonCall.GIL.@lock region #751
using Base.Threads
using PythonCall
o =Py(randn(3,3))
t = Threads.@spawnbegin
PythonCall.GIL.@lockbeginprintln(Core.stderr, propertynames(o))
endend
PythonCall.GIL.@unlockwait(t)
julia +1.12--project=. mwe.jl
CondaPkg Found dev dependencies:/home/topolarity/repos/claude/PythonCall.jl/CondaPkg.toml
CondaPkg Found dependencies:/home/topolarity/.julia/packages/CondaPkg/8GjrP/CondaPkg.toml
...
[127641] signal 11 (1): Segmentation fault
in expression starting at /home/topolarity/repos/claude/PythonCall.jl/mwe.jl:9
_PyInterpreterState_GET at /usr/local/src/conda/python-3.14.3/Include/internal/pycore_pystate.h:211 [inlined]
get_type_cache at /usr/local/src/conda/python-3.14.3/Objects/typeobject.c:868 [inlined]
_PyType_LookupStackRefAndVersion at /usr/local/src/conda/python-3.14.3/Objects/typeobject.c:5798 [inlined]
_PyType_LookupRefAndVersion at /usr/local/src/conda/python-3.14.3/Objects/typeobject.c:5784 [inlined]
_PyType_LookupRef at /usr/local/src/conda/python-3.14.3/Objects/typeobject.c:5896 [inlined]
_PyObject_LookupSpecial at /usr/local/src/conda/python-3.14.3/Objects/typeobject.c:2791
_dir_object at /usr/local/src/conda/python-3.14.3/Objects/object.c:2020 [inlined]
PyObject_Dir at /usr/local/src/conda/python-3.14.3/Objects/object.c:2052
PyObject_Dir at /home/topolarity/repos/claude/PythonCall.jl/src/C/pointers.jl:302 [inlined]
macro expansion at /home/topolarity/repos/claude/PythonCall.jl/src/Core/Py.jl:118 [inlined]
pydir at /home/topolarity/repos/claude/PythonCall.jl/src/Core/builtins.jl:191#4 at /home/topolarity/repos/claude/PythonCall.jl/src/Core/Py.jl:297
The problem is that #677 assumes the main thread is the appropriate thread to run this on, but that's not true in general if you're using the GIL / doing true multi-threading.
Activity
cjdoris commentedon May 17, 2026
Thanks for the MWE.
I think the fix is to have
propertynamescheck whether the GIL is held by the current thread and only defer to the "main" thread if not.