symengine / SymEngine.jl

Julia wrappers of SymEngine
MIT License
192 stars 43 forks source link

not throw error but crash when assign an expression to array #248

Open acsofie opened 2 years ago

acsofie commented 2 years ago

environment:

Debian ⛬  julia/1.5.3+dfsg-3

[[SymEngine]]
deps = ["Compat", "Libdl", "LinearAlgebra", "RecipesBase", "SpecialFunctions", "SymEngine_jll"]
git-tree-sha1 = "6cf88a0b98c758a36e6e978a41e8a12f6f5cdacc"
uuid = "123dc426-2d89-5057-bbad-38513e3affd8"
version = "0.8.7"

[[SymEngine_jll]]
deps = ["Artifacts", "GMP_jll", "JLLWrappers", "Libdl", "MPC_jll", "MPFR_jll", "Pkg"]
git-tree-sha1 = "e6635b196b974164519a1ce259769eaf68a41e47"
uuid = "3428059b-622b-5399-b16f-d347a77089a4"
version = "0.8.0+0"

use:

using SymEngine
@vars a
b=zeros(2)

now the type of a is Basic and the type of b is Array{Float64,1}. if we assign a Basic to an element of b, it throw an error.

julia> b[1]=a
ERROR: ArgumentError: symbolic value cannot be evaluated to a numeric value
Stacktrace:
 [1] evalf(::Basic, ::Int64, ::Bool) at /home/chen/.julia/packages/SymEngine/OE2Ff/src/numerics.jl:14
 [2] convert(::Type{Float64}, ::Basic) at /home/chen/.julia/packages/SymEngine/OE2Ff/src/numerics.jl:184
 [3] setindex!(::Array{Float64,1}, ::Basic, ::Int64) at ./array.jl:847
 [4] top-level scope at REPL[7]:1

This is acceptable. However, if use an expression, then

julia> b[1]=a+1

signal (6): abort
in expression starting at REPL[7]:1
gsignal at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fd9c26d73a5)
_ZNK9SymEngine3Add6acceptERNS_26EvalRealDoubleVisitorFinalE at /home/user/.julia/artifacts/ba7d931a7fe8b6f27199040e456a4aab6264f0d7/lib/libsymengine.so (unknown line)
unknown function (ip: (nil))
Allocations: 13033709 (Pool: 13027579; Big: 6130); GC: 13
abort

julia crash completely. This situation may need an ArgumentError.

isuruf commented 2 years ago

I can't reproduce this.

julia> using SymEngine

julia> @vars a
(a,)

julia> b = zeros(2)
2-element Array{Float64,1}:
 0.0
 0.0

julia> b[1]=a
ERROR: ArgumentError: symbolic value cannot be evaluated to a numeric value
Stacktrace:
 [1] evalf(::Basic, ::Int64, ::Bool) at /home/isuru/projects/SymEngine.jl/src/numerics.jl:14
 [2] convert(::Type{Float64}, ::Basic) at /home/isuru/projects/SymEngine.jl/src/numerics.jl:184
 [3] setindex!(::Array{Float64,1}, ::Basic, ::Int64) at ./array.jl:782
 [4] top-level scope at REPL[14]:1

julia> b[1]=a+1
ERROR: ArgumentError: symbolic value cannot be evaluated to a numeric value
Stacktrace:
 [1] evalf(::Basic, ::Int64, ::Bool) at /home/isuru/projects/SymEngine.jl/src/numerics.jl:14
 [2] convert(::Type{Float64}, ::Basic) at /home/isuru/projects/SymEngine.jl/src/numerics.jl:184
 [3] setindex!(::Array{Float64,1}, ::Basic, ::Int64) at ./array.jl:782
 [4] top-level scope at REPL[15]:1
acsofie commented 2 years ago

@isuruf which version of julia and SymEngine you use? I downloaded it from the official debian apt repo. Maybe debian problam?