Multithreading with PythonCall and PythonPlot leads to a EXCEPTION_ACCESS_VIOLATION
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par src\Pythoncall_testing.jl et reproduisez le crash avec Julia 1.12.5, PythonCall 0.9.31, PythonPlot 1.0.6, Windows et 10 threads. Lisez la stack trace autour de init de PythonPlot et de la ligne 198 de pyGui.jl, avec PythonCall.GIL.@unlock. Le travail est terminé lorsque l’interaction est comprise et que la violation d’accès signalée ne se produit plus dans l’exemple minimal.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Affects: PythonCall
Bug description
Having both PythonCall and PythonPlot imported leads to a EXCEPTION_ACCESS_VIOLATION when used with multithreading with an unlocked GIL.
MWE
File: src\Pythoncall_testing.jl
import PythonCall
import PythonPlot
PythonCall.GIL.@unlock Threads.@threads for i in 1:5
println("Hello world")
end
Commands
Command line:
C:\Users\kuhrmann\CODE\pythoncall_testing>julia -t 10
] activate .
include("src\\Pythoncall_testing.jl")
Output
C:\Users\kuhrmann\CODE\pythoncall_testing>julia -t 10
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.12.5 (2026-02-09)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org release
|__/ |
(@v1.12) pkg> activate .
Activating project at `C:\Users\kuhrmann\CODE\pythoncall_testing`
julia> include("src\\Pythoncall_testing.jl")
Hello world
Hello world
Hello world
Hello world
Hello world
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x7ffbe8a26c09 -- PyType_GenericAlloc at C:\Users\kuhrmann\CODE\pythoncall_testing\.CondaPkg\.pixi\envs\default\python314.dll (unknown line)
in expression starting at C:\Users\kuhrmann\CODE\pythoncall_testing\src\Pythoncall_testing.jl:4
PyType_GenericAlloc at C:\Users\kuhrmann\CODE\pythoncall_testing\.CondaPkg\.pixi\envs\default\python314.dll (unknown line)
PyUnicode_DecodeUTF8Stateful at C:\Users\kuhrmann\CODE\pythoncall_testing\.CondaPkg\.pixi\envs\default\python314.dll (unknown line)
PyUnicode_DecodeUTF8Stateful at C:\Users\kuhrmann\CODE\pythoncall_testing\.CondaPkg\.pixi\envs\default\python314.dll (unknown line)
PyUnicode_DecodeUTF8 at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\C\pointers.jl:300 [inlined]
pystr_fromUTF8 at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\builtins.jl:554
pystr_fromUTF8 at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\builtins.jl:555 [inlined]
pystr at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\builtins.jl:563 [inlined]
Py at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\Py.jl:125 [inlined]
macro expansion at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\Py.jl:117 [inlined]
pygetattr at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\builtins.jl:58
getproperty at C:\Users\kuhrmann\.julia\packages\PythonCall\83z4q\src\Core\Py.jl:275 [inlined]
#Tk_eventloop##0 at C:\Users\kuhrmann\.julia\packages\PythonPlot\oS8x4\src\pygui.jl:198
#634 at .\asyncevent.jl:361
unknown function (ip: 000001ead8510a6b) at (unknown file)
jl_apply at C:/workdir/src\julia.h:2391 [inlined]
start_task at C:/workdir/src\task.c:1252
Allocations: 3660481 (Pool: 3660333; Big: 148); GC: 5
C:\Users\kuhrmann\CODE\pythoncall_testing>
System info
Your system
Please provide detailed information about your system:
- The operating system: Win 11
- The version of Julia, Python, PythonCall, JuliaCall and any other affected packages
- If an issue with PythonCall, the output of
Base.versioninfo(),Pkg.status()andCondaPkg.status().
versioninfo()
Julia Version 1.12.5
Commit 5fe89b8ddc (2026-02-09 16:05 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 20 × 13th Gen Intel(R) Core(TM) i7-1370P
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
GC: Built with stock GC
Threads: 10 default, 1 interactive, 10 GC (on 20 virtual cores)
Pkg.status()
Project Pythoncall_testing v0.1.0
Status `C:\Users\kuhrmann\CODE\pythoncall_testing\Project.toml`
[6099a3de] PythonCall v0.9.31
[274fc56d] PythonPlot v1.0.6
CondaPkg.status()
CondaPkg Status C:\Users\kuhrmann\CODE\pythoncall_testing\CondaPkg.toml (empty)
Environment
C:\Users\kuhrmann\CODE\pythoncall_testing\.CondaPkg\.pixi\envs\default
Additional context
I dont want to use multithreading to plot on many threads, I just have a julia project in which I do multithreaded computation involving python, and the results of which I would like to plot with matplotlib.
From the stacktrace, it seems as though PythonPlot.__init__() gets called by each thread, which in turn calls python.
I belive this leads to a crash as the GIL is unlocked (PythonCall.GIL@unlock) but was not locked before the PythonPlot.__init__().
This is quite frustrating, as I need both PythonCall and PythonPlot and I would like to not have to separate them at the project level.
Is there some way to avoid this? Perhaps I can somehow make sure the the PythonPlot.__init__() calls are wrapped with PythonCall.GIL.@lock?
Let me know if something is unclear!
Thanks for the convenient package otherwise!
- Langage dominant
- Julia
- Étoiles
- 1.1k
- Forks
- 89
- Merge moyen
- 2 j 15 h
- PR mergées (30 j)
- 7
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de JuliaPy/PythonCall.jl
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
JuliaPy/PythonCall.jl#828 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
JuliaPy/PythonCall.jl#809 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Locking julia dependenciesOuverteenhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
JuliaPy/PythonCall.jl#805 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
JuliaPy/PythonCall.jl#796 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
JuliaPy/PythonCall.jl#790 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de JuliaPy/PythonCall.jl
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
oxfordcontrol/COSMO.jl#211 ·
-
documentation
Difficulté 2/5 Une demi-journée Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 6 jours
-
Out-of-place JLArray/GPU problem with VectorContinuousCallback scalar-indexes (callback cache built with CPU zeros)Peut-être pris @ChrisRackauckas-Claude l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
SciML/OrdinaryDiffEq.jl#4813 ·
Les mainteneurs répondent en général sous 1 jour
-
ARKODE: callbacks that modify `u` throw MethodError on reinitPeut-être pris @devmotion l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
SciML/Sundials.jl#575 ·
-
broken links in docsOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour