Skip to content

Segmentation error with sparse arrays #370

@MarcBerliner

Description

@MarcBerliner

It was difficult to find an MWE since Julia just kept crashing:

using Symbolics, SparseArrays

@variables x y[1:4]

z = Symbolics.Num[
    0
    -x*((1//3)*y[1] + (1//12)*y[2] + (1//6)*y[3] + (1//9)*y[4])*((y[1] + y[2] + y[3] + y[4])^-1)
]

sparse(z)
zsh: segmentation fault  /Applications/Julia-1.6.app/Contents/Resources/julia/bin/julia

If you use convert

convert(SparseVector{Num, Int64},z)
ERROR: StackOverflowError:
Stacktrace:
      [1] promote_type
        @ ./promotion.jl:233 [inlined]
      [2] promote_result(#unused#::Type, #unused#::Type, #unused#::Type{DynamicPolynomials.Term{true, Any}}, #unused#::Type{Any})
        @ Base ./promotion.jl:247
--- the last 2 lines are repeated 79982 more times ---
 [159967] promote_type
        @ ./promotion.jl:233 [inlined]

Interestingly, if you remove the negative sign on x it works just fine.

I'm using Symbolics v3.2.3.

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