Skip to content

Unclear error (Segmentation Fault) when trying to store System as global variable within package #646

@miles-1

Description

@miles-1

If you try to make a package that stores the results of a System call as a global variable, the REPL crashes with a "Segmention fault" error (full error message below). I imagine this crash behavior is not intended, even if this structure is not recommended for using Systems. I made an MRE with the following file structure & contents:

project_dir
 ├ HC
 │ ├ src
 │ │ ╰ HC.jl
 │ ├ Manifest.toml
 │ ╰ Project.toml
 ╰ run_model.jl

HC.jl:

module HC

using HomotopyContinuation: @var, System, solve, real_solutions

@var S I
@var r d β μ

export get_eqs

_symbolic_model = System(
    [
        r * (S + I) - d * S - β * S * I,
        β * S * I - (d + μ) * I
    ],
    variables = [S, I],
    parameters = [r, d, β, μ]
)

function get_eqs(
    p_set::Vector{Float64}
)::Vector
    result = solve(
        _symbolic_model,
        target_parameters = p_set,
        show_progress = false,
        threading = false,
    )
    return real_solutions(result)
end

end

run_model.jl:

using HC

for i in 0.1:0.1:0.5
    get_eqs([2, 0.5, 0.5, i])
end

resulting error:

[71867] signal 11 (1): Segmentation fault: 11
in expression starting at /Users/miles/test/run_model.jl:3
_ZNSt3__16__treeINS_12__value_typeIN9SymEngine3RCPIKNS2_5BasicEEES6_EENS_19__map_value_compareIS6_S7_NS2_15RCPBasicKeyLessELb1EEENS_9allocatorIS7_EEE12__find_equalIS6_EERPNS_16__tree_node_baseIPvEERPNS_15__tree_end_nodeISI_EERKT_ at /Users/miles/.julia/artifacts/72bbdc1bf66a1722a793e6fb95d39c18029d3937/lib/libsymengine.0.9.0.dylib (unknown line)
mapbasicbasic_insert at /Users/miles/.julia/artifacts/72bbdc1bf66a1722a793e6fb95d39c18029d3937/lib/libsymengine.0.9.0.dylib (unknown line)
setindex! at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/model_kit/symengine.jl:887
CompiledSystem at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/model_kit/compiled_system_homotopy.jl:32
#MixedSystem#59 at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/systems/mixed_system.jl:13
MixedSystem at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/systems/mixed_system.jl:13 [inlined]
#fixed#80 at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/systems.jl:23
fixed at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/systems.jl:17 [inlined]
#polyhedral#223 at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/polyhedral.jl:174
polyhedral at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/polyhedral.jl:167 [inlined]
#solver_startsolutions#270 at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/solve.jl:161
solver_startsolutions at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/solve.jl:115 [inlined]
solver_startsolutions at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/solve.jl:115 [inlined]
#solve#277 at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/solve.jl:468
solve at /Users/miles/.julia/packages/HomotopyContinuation/Cibx5/src/solve.jl:435
unknown function (ip: 0x10ef5777e)
get_eqs at /Users/miles/test/HC/src/HC.jl:22
top-level scope at /Users/miles/test/run_model.jl:4
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/toplevel.c:934
jl_toplevel_eval_flex at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/toplevel.c:886
ijl_toplevel_eval at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/toplevel.c:952 [inlined]
ijl_toplevel_eval_in at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/toplevel.c:994
eval at ./boot.jl:430 [inlined]
include_string at ./loading.jl:2734
_include at ./loading.jl:2794
include at ./Base.jl:557
jfptr_include_47031.1 at /Users/miles/.julia/juliaup/julia-1.11.5+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
exec_options at ./client.jl:323
_start at ./client.jl:531
jfptr__start_73719.1 at /Users/miles/.julia/juliaup/julia-1.11.5+0.x64.apple.darwin14/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/./julia.h:2157 [inlined]
true_main at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/jlapi.c:900
jl_repl_entrypoint at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZQ07RJYVY.0/build/default-grannysmith-C07ZQ07RJYVY-0/julialang/julia-release-1-dot-11/src/jlapi.c:1059
Allocations: 79930818 (Pool: 79928292; Big: 2526); GC: 36
zsh: segmentation fault  julia run_model.jl

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions