Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation error with sparse arrays #370

Closed
MarcBerliner opened this issue Sep 2, 2021 · 2 comments
Closed

Segmentation error with sparse arrays #370

MarcBerliner opened this issue Sep 2, 2021 · 2 comments

Comments

@MarcBerliner
Copy link

MarcBerliner commented Sep 2, 2021

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.

@MarcBerliner
Copy link
Author

@moble
Copy link
Contributor

moble commented Sep 17, 2021

A workaround would be to define

y = [Symbolics.variable(:y, i) for i in 1:4]

I don't think this should be necessary, though; see #379.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants