ITADN

`propertynames` segfaults when called inside `PythonCall.GIL.@lock` region

#751Opentopolarity 创建于 2026-03-10
bug
T
topolaritycommented
```julia using Base.Threads using PythonCall o = Py(randn(3,3)) t = Threads.@spawn begin PythonCall.GIL.@lock begin println(Core.stderr, propertynames(o)) end end PythonCall.GIL.@unlock wait(t) ``` ```julia 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 https://github.com/JuliaPy/PythonCall.jl/pull/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.
0 条评论