# Segmentation fault using SymPy

**URL:** <https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262>\
**Category:** General Usage\
**Created:** [October 26, 2026, 11:40am UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262 "2026-10-26T11:40:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![runjaj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/runjaj/32/23628_2.png) [@runjaj](https://discourse.julialang.org/u/runjaj)\
**Post date:** [October 26, 2026, 11:40am UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262/1 "2026-10-26T11:40:21Z")

</div>

I’m suffering a segmentation fault using Sympy v.2.3.3 and I have no idea how to solve this problem.

My system is:

```julia-auto
Julia Version 1.13.3
Commit 67ac47b9cd8 (2026-10-25 15:28 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × 13th Gen Intel(R) Core(TM) i7-13700
  WORD_SIZE: 64
  LLVM: libLLVM-20.1.8 (ORCJIT, raptorlake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 24 virtual cores)

```

A mwe to get the segmentation fault is:

```julia
julia> using SymPy

julia> @syms c() a
(c, a)

julia> Dict(c(0)=>a)

```

and the error message is (`Violación de segmento` is Segmentation fault in Spanish):

```julia-auto
[80536] signal 11 (1): Violación de segmento
in expression starting at REPL[6]:1
_PyInterpreterState_GET at /usr/local/src/conda/python-split-3.14.9/Include/internal/pycore_pystate.h:228 [inlined]
get_type_cache at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:938 [inlined]
_PyType_LookupStackRefAndVersion at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:5893 [inlined]
lookup_method_ex at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:2901 [inlined]
lookup_maybe_method at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:2935 [inlined]
maybe_call_special_no_args at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:3071 [inlined]
slot_tp_hash at /usr/local/src/conda/python-split-3.14.9/Objects/typeobject.c:10319
hash at /home/javier/.julia/packages/SymPy/hO96Y/src/python_connection.jl:75 [inlined]
hash at ./hashing.jl:40 [inlined]
hashindex at ./dict.jl:129 [inlined]
ht_keyindex2_shorthash! at ./dict.jl:276
setindex! at ./dict.jl:358
Dict at ./dict.jl:94
Dict at ./dict.jl:114
unknown function (ip: 0x7a4c449a6922) at (unknown file)
jl_apply at /cache/build/builder-amdci4-1/julialang/julia-ci/src/julia.h:2319 [inlined]
do_call at /cache/build/builder-amdci4-1/julialang/julia-ci/src/interpreter.c:123
eval_value at /cache/build/builder-amdci4-1/julialang/julia-ci/src/interpreter.c:243
eval_stmt_value at /cache/build/builder-amdci4-1/julialang/julia-ci/src/interpreter.c:194 [inlined]
eval_body at /cache/build/builder-amdci4-1/julialang/julia-ci/src/interpreter.c:679
jl_interpret_toplevel_thunk at /cache/build/builder-amdci4-1/julialang/julia-ci/src/interpreter.c:884
jl_toplevel_eval_flex at /cache/build/builder-amdci4-1/julialang/julia-ci/src/toplevel.c:742
__repl_entry_eval_expanded_with_loc at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:313
toplevel_eval_with_hooks at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:320
toplevel_eval_with_hooks at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:324
toplevel_eval_with_hooks at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:324
toplevel_eval_with_hooks at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:324
toplevel_eval_with_hooks at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:317 [inlined]
eval_user_input at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:342
repl_backend_loop at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:484
#start_repl_backend#41 at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:444
start_repl_backend at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:441 [inlined]
#run_repl#50 at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:707
run_repl at /cache/build/builder-amdci4-1/julialang/julia-ci/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:692
jfptr_run_repl_19138.1 at /home/javier/.julia/juliaup/julia-1.13.3+0.x64.linux.gnu/share/julia/compiled/v1.13/REPL/u0gqU_YVq3P.so (unknown line)
run_std_repl at ./client.jl:505
jfptr_run_std_repl_71330.1 at /home/javier/.julia/juliaup/julia-1.13.3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
run_main_repl at ./client.jl:526
repl_main at ./client.jl:618 [inlined]
_start at ./client.jl:588
jfptr__start_57951.1 at /home/javier/.julia/juliaup/julia-1.13.3+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
jl_apply at /cache/build/builder-amdci4-1/julialang/julia-ci/src/julia.h:2319 [inlined]
true_main at /cache/build/builder-amdci4-1/julialang/julia-ci/src/jlapi.c:985
jl_repl_entrypoint at /cache/build/builder-amdci4-1/julialang/julia-ci/src/jlapi.c:1152
main at /cache/build/builder-amdci4-1/julialang/julia-ci/cli/loader_exe.c:58
unknown function (ip: 0x7a4c5e42a600) at /usr/lib/x86_64-linux-gnu/libc.so.6
__libc_start_main at /usr/lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8) at /workspace/srcdir/glibc-2.17/csu/../sysdeps/x86_64/start.S
Allocations: 14032208 (Pool: 14029791; Big: 2417); GC: 16
Violación de segmento (`core' generado) julia --project

```

Please, let me know if you need more information to find where the problem is.

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [October 26, 2026, 11:44am UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262/2 "2026-10-26T11:44:09Z")

</div>

this looks like a bug in `SymPy.jl` . it defines many methods on `==`, but not the corresponding required methods on `hash`.

---

<div class="post-metadata">

**Author:** ![runjaj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/runjaj/32/23628_2.png) [@runjaj](https://discourse.julialang.org/u/runjaj)\
**Post date:** [October 26, 2026, 12:29pm UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262/3 "2026-10-26T12:29:26Z")

</div>

It seems that the problem is with `PyCall.jl`. I added `PyCall@1.96.4`, did `build PyCall` and it seems that it is working now.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [October 26, 2026, 2:38pm UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262/4 "2026-10-26T14:38:45Z")

</div>

[GitHub - jverzani/SymPyPythonCall.jl: SymPy with PythonCall backend (not PyCall) · GitHub](https://github.com/jverzani/SymPyPythonCall.jl) works more reliably. In particular, it is thread safe, which PyCall isn’t.

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [October 26, 2026, 4:50pm UTC](https://discourse.julialang.org/t/segmentation-fault-using-sympy/140262/5 "2026-10-26T16:50:23Z")

</div>

Thanks. This is addressed in [Fix hash segfault with PyCall 1.97 - Pull Request #565 - JuliaPy/SymPy.jl - GitHub](https://github.com/JuliaPy/SymPy.jl/pull/565). A new version was registered.
