JuliaPy / JuliaPy/PythonCall.jl

Segfault on M3 when loading specific Python subpackage

Aberta
#518 1 comentário 0 reações 0 responsáveis Ver no GitHub
bug
Linguagem predominante
Julia
Estrelas
1.1k
Forks
86
Merge médio
1d 22h
PRs com merge (30d)
3

Descrição

**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:

```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.