JuliaPy / JuliaPy/PythonCall.jl
Segfault on M3 when loading specific Python subpackage
- Langage dominant
- Julia
- Étoiles
- 1.1k
- Forks
- 86
- Merge moyen
- 1 j 22 h
- PR mergées (30 j)
- 3
Description
**Affects:** PythonCall
**Describe the bug**
On a M3 Mac I can produce a segfault when loading a specific subpackage, `simpeg.potential_fields` from version 0.22.0 of the `simpeg` package (https://github.com/simpeg/simpeg). When I import just 'simpeg', there is no segfault. Furthermore, other subpackages do not produce segfaults when loaded, e.g., `simpeg.maps`.
Here are the commands used to reproduce the segfault. (The output of some steps has been shortened; I will include a full output in a reply.)
```julia
(@v1.10) pkg> activate --temp
Activating new project at `/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS`
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M3 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores)
Environment:
JULIA_PKG_USE_CLI_GIT = 1
(jl_tI92dS) pkg> add CondaPkg PythonCall
Resolving package versions...
Updating `/private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/Project.toml`
[992eb4ea] + CondaPkg v0.2.22
[6099a3de] + PythonCall v0.9.20
...
julia> using CondaPkg
(jl_wZlac1) pkg> conda add simpeg
CondaPkg Found dependencies: /var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/CondaPkg.toml
CondaPkg Found dependencies: /Users/williamdavis/.julia/packages/PythonCall/S5MOg/CondaPkg.toml
CondaPkg Resolving changes
+ python
+ simpeg
CondaPkg Creating environment
...
+ simpeg 0.22.0 pyhd8ed1ab_0 conda-forge Cached
...
Transaction finished
To activate this environment, use:
micromamba activate /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/.CondaPkg/env
julia> using PythonCall
CondaPkg Found dependencies: /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/CondaPkg.toml
CondaPkg Found dependencies: /Users/williamdavis/.julia/packages/PythonCall/S5MOg/CondaPkg.toml
CondaPkg Removing environment
│ /Users/williamdavis/.julia/artifacts/98aba21a6802e06a5d2e7c48633d7dc1c3d4a749/bin/micromamba
│ -r /Users/williamdavis/.julia/scratchspaces/0b3b1443-0f03-428d-bdfb-f27f9c1191ea/root
│ remove
│ -y
│ -p /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/.CondaPkg/env
└ --all
...
CondaPkg Creating environment
│ /Users/williamdavis/.julia/artifacts/98aba21a6802e06a5d2e7c48633d7dc1c3d4a749/bin/micromamba
│ -r /Users/williamdavis/.julia/scratchspaces/0b3b1443-0f03-428d-bdfb-f27f9c1191ea/root
│ create
│ -y
│ -p /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/.CondaPkg/env
│ --override-channels
│ --no-channel-priority
│ python[version='>=3.8,<4',channel='conda-forge',build='*cpython*']
│ simpeg[version='*']
└ -c conda-forge
...
julia> pyimport("simpeg")
Python:
julia> pyimport("simpeg.maps")
Python:
julia> pyimport("simpeg.potential_fields")
[50910] signal (11.2): Segmentation fault: 11
in expression starting at REPL[16]:1
_ZN4llvm17PMTopLevelManager16addImmutablePassEPNS_13ImmutablePassE at /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/.CondaPkg/env/lib/libLLVM-14.dylib (unknown line)
Allocations: 10142116 (Pool: 10132215; Big: 9901); GC: 16
zsh: segmentation fault julia
```
**Your system**
Running on a MacBook Pro M3, with macOS Sonoma 14.5 (23F79).
Output of `Base.versioninfo()`
```julia
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M3 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 6 virtual cores)
Environment:
JULIA_PKG_USE_CLI_GIT = 1
```
Output of `Pkg.status()`
```julia
Status `/private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/Project.toml`
[992eb4ea] CondaPkg v0.2.22
[6099a3de] PythonCall v0.9.20
```
Output of `CondaPkg.status()`
```julia
CondaPkg Status /private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/CondaPkg.toml
Environment
/private/var/folders/8q/1dg0hln57_xgmstm42jkdxpr0000gn/T/jl_tI92dS/.CondaPkg/env
Packages
simpeg v0.22.0
```
**Additional context**
- Running Python (from `.CondaPkg/env`) and importing `simpeg.potential_fields` directly does not cause a segfault, see example below.
- This segfault does not occur with `simpeg` version 0.21, and the version 0.21->0.22 changed the package name from `SimPEG` to `simpeg`.
- This bug is similar to issue [#315](https://github.com/JuliaPy/PythonCall.jl/issues/315), except this bug is specific to a *subpackage*
```julia
(@v1.10) pkg> activate --temp
...
(jl_yP78nT) pkg> add CondaPkg PythonCall
julia> using CondaPkg
(jl_yP78nT) pkg> conda add simpeg=0.21
...
julia> using PythonCall
...
julia> pyimport("SimPEG")
Python:
julia> pyimport("SimPEG.maps")
Python:
julia> pyimport("SimPEG.potential_fields")
Python:
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Start with the minimal Julia environment shown, using CondaPkg and PythonCall to reproduce the crash at pyimport("simpeg.potential_fields"). Compare the simpeg 0.21 and 0.22 cases and review related issue #315. Done means importing the subpackage no longer segfaults on the reported M3 setup.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 35/100