symengine / SymEngine.jl

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

Segfault with deserialize #198

Closed dionisos2 closed 2 years ago

dionisos2 commented 4 years ago

Working example that will segfault :

using SymEngine
using Serialization
@vars x
serialize("serial_file", Dict(x=>1))
deserialize("serial_file")

Expected behavior : Throw a error about it being impossible to serialize/deserialize Basic object or make it works.

Probable cause : Julia reconstructs the Basic object x containing a pointer. To build the Dict , it then hashes x . Hashing of a Basic type is defined by basic_hash(ex::Basic) = ccall((:basic_hash, libsymengine), UInt, (Ref{Basic}, ), ex)

isuruf commented 4 years ago

Throw a error about it being impossible to serialize/deserialize Basic object or make it works.

I'm open to either. How can I do that?

dionisos2 commented 4 years ago

Unfortunately I am a novice and I have no idea of what is the correct way to do that.

PerformanceCoder commented 2 years ago

It seems that after adding basic_dumps and basic_loads in the C wrapper, serialization can be implemented in SymEngine.jl.

I have a draft code for dumps/loads in SymEngine.jl but unfortunately I don't fully understand how SymEngine_jll generation happens. There should be a new release of SymEngine to regenerate it?

isuruf commented 2 years ago

Fixed in #254 thanks to @PerformanceCoder.